0

I've connected a UILongPressGestureRecognizer to my Button on the view. I did this in the Referencing Outlet Collections in in the Interface Builder. When the Button gets pressed an Action is triggered:

 - (IBAction)longPressed:(UILongPressGestureRecognizer *)sender {
    [self performSegueWithIdentifier:@"nextView" sender:self];
}

The segue was created in the Interfacebuilder.

The next ViewController is pushed (I use a NavigationController) and displayed correct. But now I get this Error Message:

"nested push animation can result in corrupted navigation bar" "Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted." "Unbalanced calls to begin/end appearance transitions for ."

When I press the back Button the App crashes.

I tried to trigger the segue with a simple Button touch. It works, but why does it crash with the LongPress.

user2415476
  • 211
  • 1
  • 15

1 Answers1

2

logPressed gets called multiple times with different states. You need to add code in there to only fire the event for one of the states.

Read up on this answer.

And put in code something like this with whatever state you want to accept.

-  (void)handleLongPress:(UILongPressGestureRecognizer*)sender { 
    if (sender.state == UIGestureRecognizerStateEnded) {
      NSLog(@"UIGestureRecognizerStateEnded");
    //Do Whatever You want on End of Gesture
     }
    else if (sender.state == UIGestureRecognizerStateBegan){
       NSLog(@"UIGestureRecognizerStateBegan.");
   //Do Whatever You want on Began of Gesture
     }
  }

I would suggest this state: UIGestureRecognizerStateRecognized

Community
  • 1
  • 1
Putz1103
  • 6,211
  • 1
  • 18
  • 25