我正在使用 xcode 4.5.2 的主从模板。我没有将其保留UINavigationController
为rootViewController
,UIWindow
而是用我自己的 ViewController 替换它,并用一个简单的闪屏作为它的视图。显示初始屏幕后,我想将navigationController
as self.window.rootviewController
(包含 master 和detailViewControllers
)推送。
问题是虽然我ViewController
正在初始化并且它viewDidLoad
被调用但它的视图(启动屏幕没有显示)。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{LoginViewController *loginViewController = [[[LoginViewController alloc] initWithNibName:@"LoginViewController_iPhone" bundle:nil] autorelease];
// loginViewController.masterViewController = loginViewController;
[self.window setRootViewController:loginViewController];
[self.window addSubview:loginViewController.view];
if (BOOL condition is YES)
{
MasterViewController *masterViewController = [[[MasterViewController alloc] initWithNibName:@"MasterViewController_iPhone" bundle:nil] autorelease];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
//self.window.rootViewController = self.navigationController;
}
LoginViewController
是带有闪屏的自定义控制器。那么如何在使用导航控制器时从 App 委托更改启动屏幕?(主从模板)