我一直在寻找一些代码,它会在加载其他视图之前首先显示一个Login Modal窗口。
我创建了一个Login nib,在applicationDidFinishLaunching appdelegate中我使用了这段代码:
[window addSubview:splitViewController.view];
IntroView *introViewController=[[[IntroView alloc] initWithNibName:@"IntroView" bundle:nil]autorelease];
[introViewController setModalPresentationStyle:UIModalPresentationFullScreen] ;
[self.splitViewController presentModalViewController:introViewController animated:NO];
[window makeKeyAndVisible];
...
运行时,模态窗口不会显示,但是当我对其进行NSLog时它会被加载。 知道为什么没有显示吗?
答案 0 :(得分:0)
我的应用程序以拆分视图开始,如果没有活动会话(在核心数据实体中定义),则打开模态登录窗口。
将viewDidAppear方法添加到初始详细信息视图控制器中
为新的登录视图控制器创建模态segue
在登录视图中登录,然后使用“[self dismissModalViewControllerAnimated:YES];”
- (void)viewDidAppear:(BOOL)animated<br>
{
[super viewDidAppear:animated];
// Check if a existing session is open, if not the login screen will appear.
// When user logs on an open session record is added to the table. Closed on user logout.
userProfile = [LogonSessionManager getCurrentPtuser:managedObjectContext];
if(userProfile == nil){
[self performSegueWithIdentifier:@"login" sender:self];
} else {
// We have a user - do user config display stuff
}
}
答案 1 :(得分:0)
@greentor:你的答案并不完全正确。正确的模态segue应该来自主SplitView。这意味着您必须调用DetailViewController#viewDidAppear:
[self.splitViewController performSegueWithIdentifier:@"login" sender:self.splitViewController];