Unbalanced calls to begin/end appearance transitions for

后端 未结 22 1859
长情又很酷
长情又很酷 2020-11-28 19:23

I read SO about another user encountering similar error, but this error is in different case.

I received this message when I added a View Controller initially:

相关标签:
22条回答
  • 2020-11-28 20:01

    I encountered this error when I hooked a UIButton to a storyboard segue action (in IB) but later decided to have the button programatically call performSegueWithIdentifier forgetting to remove the first one from IB.

    In essence it performed the segue call twice, gave this error and actually pushed my view twice. The fix was to remove one of the segue calls.

    Hope this helps someone as tired as me!

    0 讨论(0)
  • 2020-11-28 20:02

    I found that, if you are using a storyboard, you will want to put the code that is presenting the new view controller in viewDidAppear. It will also get rid of the "Presenting view controllers on detached view controllers is discouraged" warning.

    0 讨论(0)
  • 2020-11-28 20:02

    I had the same issue. When developing I wanted to bypass screens. I was navigating from one view controller to another in viewDidLoad by calling a selector method.

    The issue is that we should let the ViewController finish transitioning before transitioning to another ViewController.

    This solved my problem: The delay is necessary to allow ViewControllers finish transitioning before transitioning to another.

    self.perform(#selector(YOUR SELECTOR METHOD), with: self, afterDelay: 0.5)
    
    
    0 讨论(0)
  • 2020-11-28 20:03

    I had the same problem and thought I would post in case someone else runs into something similar.

    In my case, I had attached a long press gesture recognizer to my UITableViewController.

    UILongPressGestureRecognizer *longPressGesture = [[[UILongPressGestureRecognizer alloc]
                                                       initWithTarget:self
                                                       action:@selector(onLongPress:)]
                                                      autorelease];
    [longPressGesture setMinimumPressDuration:1];
    [self.tableView addGestureRecognizer:longPressGesture];
    

    In my onLongPress selector, I launched my next view controller.

    - (IBAction)onLongPress:(id)sender {
    
        SomeViewController* page = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:nil];
    
        [self.navigationController pushViewController:page animated:YES];
    
        [page release];
    
    }
    

    In my case, I received the error message because the long press recognizer fired more than one time and as a result, my "SomeViewController" was pushed onto the stack multiple times.

    The solution was to add a boolean to indicate when the SomeViewController had been pushed onto the stack. When my UITableViewController's viewWillAppear method was called, I set the boolean back to NO.

    0 讨论(0)
  • 2020-11-28 20:03

    Actually you need to wait till the push animation ends. So you can delegate UINavigationController and prevent pushing till the animation ends.

    - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
        waitNavigation = NO;
    }
    
    
    -(void)showGScreen:(id)gvc{
    
        if (!waitNavigation) {
            waitNavigation = YES;
            [_nav popToRootViewControllerAnimated:NO];
            [_nav pushViewController:gvc animated:YES];
        }
    }
    
    0 讨论(0)
  • 2020-11-28 20:06

    you need make sure -(void)beginAppearanceTransition:(BOOL)isAppearing animated:(BOOL)animated and -(void)endAppearanceTransition is create together in the class.

    0 讨论(0)
提交回复
热议问题