我在5.0前的版本用UITabBarController一切正常,但当升级到5.0后,切换UITabBarController,则直接报异常:
Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<UINavigationController: 0x86cd260> should have parent view controller:<RootViewController: 0x84cf570> but actual parent is:<UITabBarController: 0x84d7a70>'
修改办法,在UITabBarControllerDelegate的实现类中(一般是viewDidLoad函数中)
将
self.view = tabBarController.view;
修改为:
[self.view addSubview:tabBarController.view];
本文介绍了一个在iOS 5.0中使用UITabBarController时遇到的异常问题,即应用因UIViewControllerHierarchyInconsistency错误而崩溃。文中提供了解决方案,通过调整UITabBarControllerDelegate的实现类中的代码来修复此问题。
1131

被折叠的 条评论
为什么被折叠?



