【发布时间】:2016-10-19 18:41:31
【问题描述】:
我想从 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];
【问题讨论】:
-
你写这段代码的地方,尝试使用一些延迟
-
检查“Main”是否确实存在,并且您没有在 mainStoryboard 中获得 nil 值。
-
感谢@Wolverine 的回复,我在应用委托的didFinishLaunchingWithOptions 中写了这个。
-
尝试使用调用此代码有一些延迟。 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ // 你的代码展示 });
-
感谢@mohsin,“主要”故事板存在。
标签: ios objective-c appdelegate scene