2016-10-19 2 views
0

Je veux appeler une scène story-board [storyboard ID : MyScene] de appDelegate,Appel scène Storyboard de délégué app

Je l'ai cherché et essayé beaucoup réponse donnée en cas de débordement de la pile !! mais n'a pas pu trouver de solution de travail.

Un du code j'ai essayé,

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

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

Si vous écrivez ce code, essayez d'utiliser un certain retard – Wolverine

+0

Vérifiez que « Main » est en réalité existante et que vous ne reçoivent pas une valeur nulle dans mainStoryboard. – mohsin

+0

merci pour la réponse @Wolverine, j'ai écrit cela dans didFinishLaunchingWithOptions de délégué de l'application .. –

Répondre

0

Essayez d'utiliser ce code avec appel un certain retard.

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]; 

});