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

前端 未结 24 1875
滥情空心
滥情空心 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:26

    In Xcode 6.3, you can show the launch screen.xib and even put a indicator on it, first it will show the default launch screen it is replaced by the nib so the user doesn't know it changed and then if everything is loaded hide it :-)

        func showLaunchScreen() {
        // show launchscreen
        launchView = NSBundle.mainBundle().loadNibNamed("LaunchScreen", owner: self, options: nil)[0] as! UIView
        launchView.frame = self.view.bounds;
        self.view.addSubview(launchView)
    
        // show indicator
        launchScreenIndicator = UIActivityIndicatorView(frame: CGRectMake(0, 0, 50, 50)) as UIActivityIndicatorView
        launchScreenIndicator.center = CGPointMake(self.view.center.x, self.view.center.y+100)
        launchScreenIndicator.hidesWhenStopped = true
        launchScreenIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
        launchView.addSubview(launchScreenIndicator)
        self.view.addSubview(launchView)
        launchScreenIndicator.startAnimating()
    
        self.navigationController?.setNavigationBarHidden(self.navigationController?.navigationBarHidden == false, animated: true) //or animated: false
    }
    
    func removeLaunchScreen() {
        println("remove launchscreen")
        self.launchView.removeFromSuperview()
        self.launchScreenIndicator.stopAnimating()
        self.navigationController?.setNavigationBarHidden(false, animated: true)
    }
    

提交回复
热议问题