简体   繁体   English

为什么在applicationDidFinishLaunchingWithOptions中未显示模态视图控制器?

[英]Why is the modal view controller not being presented in applicationDidFinishLaunchingWithOptions?

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. application:didFinishLaunchingWithOptions:方法中提供模态视图控制器的调用不提供视图控制器,而在applicationDidBecomeActive:则提供视图控制器。 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) 编辑 :我想提一下,根据下面的评论,我正在使用一个故事板,并且self.window.rootViewController确实指向一个对象(基本上,它不是nil)

From the UIApplicationDelegate Protocol Manual Reference: 从《 UIApplicationDelegate协议手册参考》中:

It is called after your application has been launched and its main nib file has been loaded. 在启动应用程序并加载其主要nib文件之后,将调用它。 At the time this method is called, your application is in the inactive state. 在调用此方法时,您的应用程序处于非活动状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何知道视图控制器是作为弹出窗口还是模态显示? - How to know if a view controller will be presented as a popover or modal? IOS:如何在呈现的模态视图 controller 之上放置一些视图? - IOS: How to put some view on top of presented modal view controller? 当呈现为模态视图控制器时,ARC UINavigationController堆栈未被释放 - ARC UINavigationController stack not getting deallocated when presented as modal view controller 关闭呈现的视图控制器 - Dismissing a Presented View Controller 在关闭模型视图时如何从提供的模态视图控制器中调用rootviewcontroller中的方法 - How to call a method in the rootviewcontroller from a presented modal view controller at the time of dismissing the model view 为什么“现在的模态视图控制器”? - why “present modal view controller”? 如何从呈现为半模式的视图控制器中将视图控制器推为全屏 - How to push a view controller as a full screen from the view controller presented as a half-modal iPhone - 删除显示的视图控制器 - iPhone - Removing a presented view controller UIViewController -dealloc在解除模态视图控制器后被调用 - UIViewController -dealloc Being Called After Dismissing Modal View Controller 从当前呈现的模态视图中呈现模态视图 - present a modal view from a modal view currently presented
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM