Is UISwipeGestureRecognizer called twice?

I have a problem with calling UISwipeGestureRecognize twice, I created a tabbarcontroller based application that has 4 tabs. On each tab that has a UINavigationController in that UIViewController, there I have changed the code below in the third 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 left the swipe in the simulator, it calls "didSwipeLeft", when control reaches the line [self.tabBarController setSelectedIndex:0], the (didSwipeLeft) function calls again. Please help me how to solve the problem, does anyone have the same problem. Thanks at Advance.

+3
source share
1 answer

UIImagePickerController, int. Punt int bool reset , in didSwipeLeft , , . , .

+1

Source: https://habr.com/ru/post/1783218/


All Articles