【发布时间】:2015-02-25 20:40:15
【问题描述】:
我的应用程序出现了一个非常奇怪的错误。该应用程序有两个选项卡。选项卡二显示报告列表。如果我在选项卡二中点击其中一个报告,应用程序会正确显示报告的详细信息。然后我点击标签一并立即点击标签二。该应用在 iOS 8 中崩溃,但在 iOS 7 中运行良好。
如果我在点击 Tab 1 之前返回到 Tab 2 的根视图控制器,再次点击 Tab 2 不会使应用程序崩溃。知道什么可能导致此错误吗?
在 AppDelegate 类中,我有以下代码:
- (BOOL)tabBarController:(UITabBarController *)tabBarController
shouldSelectViewController:(UIViewController *)viewController
{
UIViewController *currentController = tabBarController.selectedViewController;
if ([currentController isKindOfClass:[UINavigationController class]])
[(UINavigationController *)currentController popToRootViewControllerAnimated:NO];
return YES;
}
【问题讨论】:
-
我放了一个 if 语句来检查手机是否运行 iOS 8。应用程序已经停止崩溃。仍然不确定为什么 iOS 8 的代码会崩溃。
标签: tabbar