nikdange_me
nikdange_me

Reputation: 3017

Call Storyboard scene from app delegate

I want to call a storyboard scene [storyboard ID : MyScene] from appDelegate,

I've searched and tried many answer given on stack overflow!! but could not find working solution.

One of the code I tried,

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UIViewController *sc= (UIViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"MyScene"];

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

Upvotes: 1

Views: 643

Answers (1)

Wolverine
Wolverine

Reputation: 4329

Try using call this code with some delay.

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ 

// Your code for presenting 

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UIViewController *sc= (UIViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"MyScene"];

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

}); 

Upvotes: 1

Related Questions