Custom Splash Screen for iOS App

自古美人都是妖i 提交于 2019-12-12 02:43:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!