Unbalanced calls to begin/end appearance transitions for

后端 未结 22 1979
长情又很酷
长情又很酷 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:06

    I had this problem when I had navigated from root TVC to TVC A then to TVC B. After tapping the "load" button in TVC B I wanted to jump straight back to the root TVC (no need to revisit TVC A so why do it). I had:

    //Pop child from the nav controller
    [self.navigationController popViewControllerAnimated:YES];
    //Pop self to return to root
    [self.navigationController popViewControllerAnimated:YES];
    

    ...which gave the error "Unbalanced calls to begin/end etc". The following fixed the error, but no animation:

    //Pop child from the nav controller
    [self.navigationController popViewControllerAnimated:NO];
    //Then pop self to return to root
    [self.navigationController popViewControllerAnimated:NO];
    

    This was my final solution, no error and still animated:

    //Pop child from the nav controller
    [self.navigationController popViewControllerAnimated:NO];
    //Then pop self to return to root, only works if first pop above is *not* animated
    [self.navigationController popViewControllerAnimated:YES];
    

提交回复
热议问题