Reputation: 51
I am creating a file when the app is activated. On the basis, of the presence of that file different views get loaded.
I am trying is
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
if(condition true)
{
//[window addSubview:viewController.view];
[self.window setRootViewController:viewController];
[window makeKeyAndVisible];
return YES;
}else{
//[window addSubview:signViewController.view];
[self.window setRootViewController:secondViewController];
[window makeKeyAndVisible];
return YES;
}
// return YES;
}
Error I am getting is Application windows are expected to have a root view controller at the end of application launch
Upvotes: 1
Views: 383
Reputation: 1951
Check if you have alloc and init for view controller. use viewController=[[ViewControllerName alloc]init];
I got same error when my viewController was not allocated.
Upvotes: 0
Reputation: 9091
You should firstly alloc
and init
your view controller before you use it.
if(condition true)
{
//[window addSubview:viewController.view];
viewController = [[ViewController alloc] init];
[self.window setRootViewController:viewController];
[window makeKeyAndVisible];
return YES;
}else{
//[window addSubview:signViewController.view];
secondViewController = [[SecondViewController alloc] init];
[self.window setRootViewController:secondViewController];
[window makeKeyAndVisible];
return YES;
}
Upvotes: 1
Reputation: 1113
just write
[window makeKeyAndVisible];
return YES;
after else or before }
Upvotes: 0