Ios 从应用程序代理调用情节提要场景

Ios 从应用程序代理调用情节提要场景,ios,objective-c,appdelegate,scene,Ios,Objective C,Appdelegate,Scene,我想从appDelegate调用情节提要场景[storyboard ID:MyScene] 我已经搜索并尝试了许多关于堆栈溢出的答案!!但无法找到有效的解决方案 我尝试的代码之一, UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil]; UIViewController *sc= (UIViewController *)[mainStoryboard instantiateView

我想从appDelegate调用情节提要场景
[storyboard ID:MyScene]

我已经搜索并尝试了许多关于堆栈溢出的答案!!但无法找到有效的解决方案

我尝试的代码之一,

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

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

尝试使用调用此代码时稍有延迟

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

}); 

在编写此代码时,请尝试使用一些延迟检查“Main”是否确实存在,并且您在MainstryBoard中没有获得零值。感谢回复@Wolverine,我在didFinishLaunchingWithOptions of app delegate中编写了此代码。请尝试延迟使用调用此代码。之后调度(调度时间(现在调度时间,每秒1*NSEC),调度获取主队列(),^{///您的显示代码});谢谢@mohsin,“主”故事板存在。