在我的应用程序中,我使用推送和弹出视图控制器在 UIViewControlers 之间导航。我有一个 UIViewcontroller A 和 UIViewController B。当我单击 UIViewcontroller A 中的按钮并使用以下代码时
UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *viewController = [storybord instantiateViewControllerWithIdentifier:@"editmessage"];
[self.navigationController pushViewController:viewController animated:YES];
我能够导航到 UIViewController B。在 B 中,单击后我有一个取消按钮,我需要返回到 A。我正在使用的代码如下
NSLog(@"You did it");
[self.navigationController popViewControllerAnimated:YES];
NSLog(@"You did it again");
当我按下 UIViewcontroller A 中的按钮时,我能够导航到 UIViewcontroller B,B 的 viewdidload 方法被执行。但我在日志文件中看到以下消息。
2014-01-06 11:40:58.056 padua[5710:60b] View Did Load of editmesage controller
2014-01-06 11:40:58.231 padua[5710:60b] nested push animation can result in corrupted navigation bar
2014-01-06 11:40:58.633 padua[5710:60b] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
当我按下取消按钮时,B 的 viewdidload 再次被执行。我不确定为什么会发生这种情况,并且应用程序进入仅显示空白背景图像的状态。请在下面找到日志。请让我知道我哪里出错了。
代码
-(IBAction)cancelMessage:(id)sender{
NSLog(@"You did it");
[self.navigationController popViewControllerAnimated:YES];
NSLog(@"You did it again");
}
日志
014-01-06 11:40:58.795 padua[5710:60b] Unbalanced calls to begin/end appearance transitions for <editMessageController: 0x1900d440>.
2014-01-06 11:41:04.683 padua[5710:60b] You did it
2014-01-06 11:41:04.708 padua[5710:60b] View Did Load of editmesage controller
2014-01-06 11:41:04.769 padua[5710:60b] You did it again