这是我的故事板:
假设我在这些上方有一个登录viewController
,并且我想从那里SWRevealViewController
作为我的rootViewController
,这样它就可以完美地工作。使用下面的代码,leftMenuViewController
我可以完美地选择我的 tabBar ViewController
。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITabBarController *tabBarController = (UITabBarController *)self.revealViewController.frontViewController;
UINavigationController *navController = tabBarController.viewControllers[indexPath.row];
[navController popToRootViewControllerAnimated:NO];
tabBarController.selectedIndex = indexPath.row;
self.revealViewController.rearViewRevealOverdraw = 0.0f;
[self.revealViewController pushFrontViewController:tabBarController animated:YES];
}
App delegate
但它在或 中不起作用SignInViewController
。
- (void)checkIfUserSignedIn
{
if ([ManagerClass getBOOLTypeUserDefaultForKey:@"isSignedIn"] == YES) {
UITabBarController *tabBarController = (UITabBarController *)self.revealViewController.frontViewController;
UINavigationController *navController = tabBarController.viewControllers[0];
[navController popToRootViewControllerAnimated:NO];
tabBarController.selectedIndex = 0;
self.revealViewController.rearViewRevealOverdraw = 0.0f;
[self.revealViewController pushFrontViewController:tabBarController animated:YES];
self.window.rootViewController = tabBarController;
} else {
}
}
它在日志中给出:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application windows are expected to have a root view controller at the end of application launch'
任何帮助将不胜感激。提前非常感谢。
祝你有美好的一天。