I have a problem with UISwipeGestureRecognizer
and can't find the solution for it.
I want to use UISwipeGestureRecognizer
only on one half of the view. But I also want to use buttons on my view.
Here is what I did.
I have a UIView
named firstView
that is is 768 x 1024 px with buttons on it.
Now I want to add a UIView
or UIImageView
on top of firstView
named secondView
that is 768 x 512 px.
The swipe will work but my buttons beneath secondView
(buttons are on firstView
) won't work.
What function did I miss to make both views respond?
Or is there an even better method than I described above?
My swipe code:
UIImageView *secondView = [[[UIImageView alloc] initWithFrame:
CGRectMake(0,0,768,512)] autorelease];
//UIView *secondView = [[[UIView alloc] initWithFrame:CGRectMake(0,0,768,512)] autorelease];
secondView.userInteractionEnabled = YES;
[firstView addSubview:secondView];
oneFingerSwipeLeft = [[[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(swipeRecognition:)] autorelease];
[oneFingerSwipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[secondView addGestureRecognizer:oneFingerSwipeLeft];
I found a solution for myself. I put the screen in 4 views. Now i can give each view its own gesture recognition.
// set CGRect for downLeftView
downLeftView = [[[UIImageView alloc] initWithFrame:CGRectMake(0,512,384,512)] autorelease];
// set CGRect for downRightView
downRightView = [[[UIImageView alloc] initWithFrame:CGRectMake(384,512,384,512)] autorelease];
// set CGRect for upRightView
upRightView = [[[UIImageView alloc] initWithFrame:CGRectMake(0,0,384,512)] autorelease];
// set CGRect for upLeftView
upLeftView = [[[UIImageView alloc] initWithFrame:CGRectMake(384,0,384,512)] autorelease];