I got an error in my console and crash.
“Application windows are expected to have a root view controller at the end of application launch”
Below is my piece of code, after enter the return YES line crash will happens.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIImageView *defaultImage = [[UIImageView alloc] initWithImage:splashImage];
defaultImage.frame = defaultImageFrame;
[self.window addSubview:defaultImage];
[NSTimer scheduledTimerWithTimeInterval:3.0 target:self
selector:@selector(login:)
userInfo:nil
repeats:NO];
[self.window setBackgroundColor:[UIColor clearColor]];
[self.window makeKeyAndVisible];
return YES; // here crash will happens
}
-(void)login:(id)sender
{
PreLoginViewController *appController = [[PreLoginViewController alloc] initWithNibName:nil bundle:nil];
if (_ChooseLogin.isStatus == 105)
{
flagRequired = @"1";
appController.serverDownFlag = @"1";
}
appController.termsURL = _ChooseLogin.urlString;
appController._ChooseLogin = _ChooseLogin;
appController.rootNetworkAvailable = NO;
appController.verionMsg = versionStr;
[dft setBool:NO forKey:@"isNeedActivate"];
appController.isNeedActivate = NO;
navigationController = [[UINavigationController alloc]
initWithRootViewController:appController];
}
Any one know how to fix this issue? its workes fine in iOS 8, upto Xcode 6.3.
You need to call setRootViewController
: in your didFinishLaunchingWithOptions
: and you need a view controller to do this.
In code:
UIViewController *vc = [[UIViewController alloc] init];
[vc.view addSubview:defaultImage];
[self.window setRootViewController:vc];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With