here is my problem: In mainviewcontroller I added to swipe down gesture to switch down another view, but inside other views added to mainviewcontroller with swipe down gesture opens that specific view. However, I dont want swipe down gesture in other views rather than main view.
//---gesture recognizer
- (IBAction) handleSwipes:(UIGestureRecognizer *) sender {
UISwipeGestureRecognizerDirection direction = [(UISwipeGestureRecognizer *) sender direction];
if (direction == UISwipeGestureRecognizerDirectionDown) {
shakeController = [[ShakeViewController alloc]
initWithNibName:@"ShakeViewController" bundle:nil];
CATransition *transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromBottom;
transition.delegate = self;
// Next add it to the containerView's layer. This will perform the transition based on how we change its contents.
[self.view.layer addAnimation:transition forKey:nil];
[self.view addSubview:shakeController.view];
}
}
- (void)viewDidLoad {
[super viewDidLoad];
//gesture recognizer
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleSwipes:)];
swipeGesture.direction = UISwipeGestureRecognizerDirectionDown;
[self.view addGestureRecognizer:swipeGesture];
[swipeGesture release];
}
Thanks
You should adopt the
UIGestureRecognizerDelegateprotocol and implementgestureRecognizer:shouldReceiveTouch:method to signal whether the gesture recognizer should respond or not.