【发布时间】:2016-10-17 02:12:43
【问题描述】:
我正在使用 Xcode 7.2 和 swift 2。我在启动故事板中添加了一个启动屏幕。但是,当我运行该应用程序时,启动屏幕会很快消失。有什么方法可以自定义时间吗?
【问题讨论】:
我正在使用 Xcode 7.2 和 swift 2。我在启动故事板中添加了一个启动屏幕。但是,当我运行该应用程序时,启动屏幕会很快消失。有什么方法可以自定义时间吗?
【问题讨论】:
你可以创建一个全新的 ViewController 来显示一个启动屏幕,例如:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
self.generateRandomSplashScreen()
self.performSelector("removeSplashScreen", withObject: nil, afterDelay: <Your delay in seconds>)
self.otherViewControllerLoad()
// the other view controller
self.window.makeKeyAndVisible()
return true
}
func generateRandomSplashScreen() {
splashScreenViewController = SplashScreenController(nibName: "SplashScreenController", bundle: NSBundle.mainBundle())
self.window.addSubview(self.splashScreenViewController.view!)
}
func removeSplashScreen() {
splashScreenViewController.view!.removeFromSuperview()
self.window.rootViewController = self.tabBarController
}
【讨论】: