问题描述
我在应用程序didFinishLaunchingWithOptions中有以下代码,我想在此提供一个用于用户登录的模式视图控制器.
I have the following code in application didFinishLaunchingWithOptions where I want to present a modal view controller for user login.
LoginViewController_iPhone *loginViewController=[[LoginViewController_iPhone alloc]initWithNibName:@"LoginViewController_iPhone" bundle:nil];
UINavigationController *loginNavigationController=[[UINavigationController alloc]initWithRootViewController:loginViewController];
loginNavigationController.modalPresentationStyle=UIModalPresentationFullScreen;
[self.window.rootViewController presentModalViewController:loginNavigationController animated:NO];
[loginViewController release];
[loginNavigationController release];
但是,我得到的只是一个空白的空白屏幕.如果我替换以下内容
However, all I get is a blank white screen. If I substitute the following
self.window.rootViewController=loginNavigationController;
登录屏幕正确显示.应用刚刚启动时,没有其他视图控制器分配给rootViewController属性.我是否需要分配另一个视图控制器才能使其正常工作?
the login screen displays correctly. There is no other view controller assigned to the rootViewController property as the app is just starting. Do I need another view controller assigned to get this to work?
推荐答案
是.您需要为窗口的 rootViewController
属性分配一些内容,以调用其方法 presentModalViewController
.
Yes. you need to assign something to the window's rootViewController
property in order to call its method presentModalViewController
.
这篇关于如何在应用程序启动时显示模式视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!