自定义启动屏幕的iOS应用程序

一些谷歌search后,我发现弄乱默认的Xcode启动屏幕是不是最适当的方式让我的屏幕等待一些时间和其他的东西,所以我添加新的视图控制器(自定义类名为飞溅)到我的故事板,然后2秒将显示我的主要UINavigationController ,它不工作只是冻结在启animation面

这是我的代码:

 import UIKit class splash: UIViewController { override func viewDidLoad() { super.viewDidLoad() NSThread.sleepForTimeInterval(2.0) let vc = storyboard?.instantiateViewControllerWithIdentifier("mainmenu") as! UINavigationController self.presentViewController(vc, animated: true, completion: nil) } } 

你想做什么 – 是一个丑陋的黑客。 不要

您应该创build自定义的Splash View Controller其中包含模仿默认启动屏幕图像的布局,执行自定义animation(如果有),然后按下/呈现下一个视图控制器(在主线程上),或根据您的应用程序要求执行任何操作。

我已经解决它使用执行select器

 class splash: UIViewController { override func viewDidLoad() { super . viewDidLoad() performSelector(#selector(splash.showmainmenu), withObject: nil, afterDelay: 2) } func showmainmenu(){ performSegueWithIdentifier("mainmenu", sender: self) }