I'm having problem with UISwipeGestureRecognize called twice, I created tabbarcontroller based application which having 4 tabs. Each tab having UINavigationController under that UIViewController, there i have impelemented below code in 3rd tab.
UISwipeGestureRecognizer *swipeLeft =[[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(didSwipeLeft:)];
swipeLeft.direction=UISwipeGestureRecognizerDirectionLeft;
swipeLeft.numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:swipeLeft];
[swipeLeft release];
- (void) didSwipeLeft:(UISwipeGestureRecognizer *)sender {
NSLog(@"Left..");
if ((sender.state == UIGestureRecognizerStateEnded)) {
[self.tabBarController setSelectedIndex:0];
}
}
When i do left swipe in simulator, it is calling "didSwipeLeft" when control reaching [self.tabBarController setSelectedIndex:0] line, the function (didSwipeLeft) calling again.
Please help me, how to resolve the problem, Is anyone have faced same problem.
Thanks in Advance.
I had this kind of problem with UIImagePickerController, and I solve it with an static int. Punt an static int or bool and reset it in view will appear and in in didSwipeLeft set it, and do the action only your static is not set. Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With