问题
After some googling I found that messing with the default Xcode launch screen is not the most proper way for make ur splash screen wait for some time and other stuff so I add new view controller (custom class named splash) to my storyboard and then after 2 seconds it's will display my main UINavigationController
and it's not working just freeze on the splash screen
Here is my code:
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)
}
}
回答1:
i have solve it using perform selector
class splash: UIViewController {
override func viewDidLoad() {
super . viewDidLoad()
performSelector(#selector(splash.showmainmenu), withObject: nil, afterDelay: 2)
}
func showmainmenu(){
performSegueWithIdentifier("mainmenu", sender: self)
}
回答2:
What are you trying to do - is an ugly hack. Don't.
You should create your custom Splash View Controller
with layout that mimics your default splash screen image, perform custom animations if any, and then push/present next view controller (on the main thread), or whatever you want to do according to your app requirements.
来源:https://stackoverflow.com/questions/38747840/custom-splash-screen-for-ios-app