我在我的iPad应用程序上使用了splitViewController,但在此之前,我有一个登录名,并且在成功通过身份验证后,我刷新了根视图和详细信息视图。问题是,一旦我加载主视图没有任何反应,我尝试推送任何视图,没有事件。
当我以模态方式加载Login视图时,我收到此错误:“不平衡调用开始/结束外观转换
我使用以下命令在主视图(frontViewController)中执行登录视图:
-(void)displayLoginView:(BOOL)animated{
LoginView *loginController = [[LoginView alloc] initWithNibName:@"LoginView" bundle:nil];
[self presentModalViewController:loginController animated:YES];
}
- (void)viewDidLoad{
[super viewDidLoad];
//Add logout button
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@“Logout”style:UIBarButtonItemStyleBordered target:self action:@selector(logout)]; //如果尚未登录,请显示登录视图 [self displayLoginView:NO]; }
-(void)logout{
[self displayLoginView:YES];
}
和appdelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
FrontViewController *frontViewController;
RearViewController *rearViewController;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
frontViewController = [[FrontViewController alloc] initWithNibName:@"FrontViewController_iPhone" bundle:nil];
rearViewController = [[RearViewController alloc] initWithNibName:@"RearViewController_iPhone" bundle:nil];
}
else{
frontViewController = [[FrontViewController alloc] initWithNibName:@"FrontViewController_iPad" bundle:nil];
rearViewController = [[RearViewController alloc] initWithNibName:@"RearViewController_iPad" bundle:nil];
}
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];
RevealController *revealController = [[RevealController alloc] initWithFrontViewController:navigationController rearViewController:rearViewController];
self.viewController = revealController;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
有人可以帮助我吗?
提前多多感谢!
答案 0 :(得分:13)
检查你的viewWillAppear:animated:, viewDidAppear:animated:, viewWillDisappear:animated:, and viewDidDisappear:animated:
方法,要么你没有实现它们,要么你必须调用[super viewDid ....]。
我有相同的pb,原因是shouldAutoRotateToInterfaceOrientation:其中一个返回false而其他人返回true,我设置它们返回相同的一个它没关系。