How can I display a splash screen for longer on an iPhone?

前端 未结 24 1901
滥情空心
滥情空心 2020-11-27 11:37

How can I display a splash screen for a longer period of time than the default time on an iPhone?

24条回答
  •  再見小時候
    2020-11-27 12:17

    Swift 2.0

    Use following line in didFinishLaunchingWithOptions: delegate method:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        NSThread.sleepForTimeInterval(5.0)
        return true
    }
    

    But I recommend this:

    Put your image in a UIImageView full screen as a subview on the top of your main view thus covering your other UI. Set a timer to remove it after some seconds (possibly with effects) now showing your application.

    import UIKit
        class ViewController: UIViewController
        {
            var splashScreen:UIImageView!
            override func viewDidLoad()
            {
                super.viewDidLoad()
                self.splashScreen = UIImageView(frame: self.view.frame)
                self.splashScreen.image = UIImage(named: "Logo.png")
                self.view.addSubview(self.splashScreen)
        
                var removeSplashScreen = NSTimer.scheduledTimerWithTimeInterval(3.0, target: self, selector: "removeSplashImage", userInfo: nil, repeats: false)
            }
            func removeSplashImage()
            { 
                self.splashScreen.removeFromSuperview()
            }
        }
    

提交回复
热议问题