我正在构建一个结合了tabbar和导航栏的应用程序。在其中一个标签中,我有一个UIButton,通过触摸它,我将Tableview推入堆栈的navigationcontroller。然后,不通过按Back按钮手动返回到根视图控制器,我从tabbar切换到另一个选项卡,当我回到带有tableview的选项卡时,我得到了错误的访问错误。
我已经尝试从导航控制器堆栈中弹出tableview,或者没有释放tableview但是我无法创建它。
...谢谢
答案 0 :(得分:1)
假设您已在AppDelegate中创建了tabBar和导航控制器,则可以对应用进行编码,以便在选中时将每个选项卡返回到根视图。
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if (viewController == firstViewNavigationController) {
[firstViewNavigationController popToRootViewControllerAnimated:NO];
} else if (viewController == secondViewNavigationController) {
[secondViewNavigationController popToRootViewControllerAnimated:NO];
}
}
我正在使用它,它在我的应用程序中工作正常。我在dealloc方法中发布了我的导航控制器。我还让我的AppDelegate符合UITabBarDelegate协议。