繁体   English   中英

如何返回到IOS中的上一个视图?

[英]How to go back to previous view in IOS?

当我尝试通过从堆栈中弹出当前视图控制器返回到以前的视图控制器时,在AppDelegate.m程序中收到EXC_BAD_ACCESS错误消息。 该错误显然意味着该视图控制器不在堆栈中。

用于在AppDelegate.m程序中初始化我的第一个视图的代码如下:

  CEMMainViewController *mc = [[CEMMainViewController alloc]     
                              init];       
  UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:mc];
  self.window.rootViewController = navController;

当我想调出一个新的视图控制器时,请执行以下操作:

  CEMUpdateBurialViewController *oc = [[CEMUpdateBurialViewController  alloc] init];
  [self.navigationController pushViewController:oc animated:YES];

当我想返回上一个视图时,请执行以下操作,这将导致EXEC_BAD_ACCESS错误。 那么为什么以前的视图不出现在堆栈中呢? 我只需要知道我在做什么错。

  UINavigationController *navigationController = self.navigationController;
             [navigationController popViewControllerAnimated:YES];

使用以下代码检查您的视图控制器层次结构:

 NSLog(@"%@",self.navigationController.viewControllers);

并尝试以下方法:

[self.navigationController popToRootViewControllerAnimated:YES];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM