Teja Nandamuri
Teja Nandamuri

Reputation: 11201

Present a view controller from appdelegate

I am not using LaunchScreen.xib . I am using storyboard for splashscreen. I am calling an API to get the splash image . I am doing this in app delegate. I am able to display the image on my view controller,but I couldnt able to go to another controller once i display my image.

Here is what I have in AppDelegate:

-(void)connectionDidFinishLoading:(NSURLConnection *)connection{


self.window.frame=CGRectMake(0, 200, 100,30);

[self.window addSubview:[self convertImage: image]];

//upto here everything is fine

//now i am trying to wait for 3 seconds and call another view controller

sleep(3);

ViewController *login=[[ViewController alloc]initWithNibName:@"Login" bundle:nil];
[self presentviewcontroller:....]; // not able to present another controller

}

Upvotes: 4

Views: 7056

Answers (2)

SpaceX
SpaceX

Reputation: 2890

Swift 3

self.window?.rootViewController?.present(viewController, animated: true, completion: nil)

Upvotes: 5

Aseider
Aseider

Reputation: 5925

You could use:

[[self window].rootViewController presentViewController:login animated:YES completion:nil];

Upvotes: 5

Related Questions