为什么模态视图控制器没有出现在 applicationDidFinishLaunchingWithOptions 中?
每当应用程序运行时,我的应用程序都会呈现一个模式视图控制器(密码输入表单)。我在两个应用程序委托方法中呈现视图控制器:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self.window.rootViewController presentModalViewController:self.passcodeViewController animated:NO];
//...
return YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if (!self.passcodeViewController.view.window) {
[self.window.rootViewController presentModalViewController:self.passcodeViewController animated:NO];
}
}
在 application:didFinishLaunchingWithOptions:
方法中呈现模式视图控制器的调用不呈现视图控制器,而在 applicationDidBecomeActive 中的调用:是的。这是为什么呢?
编辑:根据下面的评论,我想提一下,我正在使用故事板,并且 self.window.rootViewController 确实指向一个对象(基本上,它不是零)
My application presents a modal view controller (a passcode entry form) whenever the application is run. I present the view controller in two application delegate methods:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self.window.rootViewController presentModalViewController:self.passcodeViewController animated:NO];
//...
return YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if (!self.passcodeViewController.view.window) {
[self.window.rootViewController presentModalViewController:self.passcodeViewController animated:NO];
}
}
The call to present the modal view controller in the application:didFinishLaunchingWithOptions:
method does not present the view controller, where as the call in applicationDidBecomeActive:
does. Why is this?
EDIT: I wanted to mention, per the comments below, that I'm using a Storyboard and that self.window.rootViewController does indeed point to an object (basically, it's not nil)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 UIApplicationDelegate 协议手册参考:
From the UIApplicationDelegate Protocol Manual Reference: