标签:iphone开发 ios 常见错误总结 跳转 push
iOS 开发过程中常出现的一些错误总结
1、两个视图控制器之间的跳转
(1)跳转:[self presentModalViewController:control animated:YES];
返回:[self dismissModalViewControllerAnimated:YES];
(2)
跳转:[self.navigationController pushViewController:subTableViewController animated:YES];
返回:[self.navigationController popViewControllerAnimated:YES];
2、【ios报错】reason: ‘Pushing anavigation controller is not supporter
reason: ‘Pushing a navigation controller is not supported‘
报上面的错误,原因是:
大家知道,可以将ViewControllerpush到一个 NavigationController中。就像是入栈操作!
将一个NavigationController再次push到NavigationController中时,报错,出現了
reason: ‘Pushing a navigation controller isnot supported‘
的错误。应该是,NavigationController不支持push进來的对象是NavigationController。将NavigationController改为viewController
3、ios 中UITableViewCell调用pushViewController:没反应(即页面视图控制器之间不能进行跳转)
总结一下使用UINavigationController遇到的一些问题:
(1)、self.navigationController==nil
(2)、[self.navigationControllerpushViewController: xxxController animate:yes]后没有back按钮;
4、Warning:Attempt to present on whose view is not in the window hierarchy!
Warning: Attempt to present on whose view is not in thewindow hierarchy!
等等这样类似的提示,只要里面提示有 windowhierarchy,都是view hierarchy的理解不到位导致的。
上面的问题都是在一个controller的view还没加到window上的时候又取present另外一个controller,这就相当于在盖楼,2楼还没盖完,直接去盖3楼了,这样肯定是不行。
遇到上面的问题 最直接的解决方法就是在controller的viewDidAppear里面去调用present。这样可以确保view hierarchy的层次结构不乱。
http://blog.csdn.net/sbvfhp/article/details/19826221
5、Presentingview controllers on detached view controllers is discouraged。
把[self.rootViewControllerpresentViewController:controller animated:YES completion:nil];
改为[self.view.Window.rootViewControllerpresentViewController:controller animated:YES completion:nil];
标签:iphone开发 ios 常见错误总结 跳转 push
原文地址:http://blog.csdn.net/eduora_meimei/article/details/44198323