简体   繁体   English

适用于iOS应用的自定义启动画面

[英]Custom Splash Screen for iOS App

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 经过一番谷歌搜索后,我发现弄乱默认的Xcode启动屏幕不是让您的启动屏幕等待一些时间和其他东西的最适当方法,因此我向情节提要中添加了新的视图控制器(名为“ splash”的自定义类),然后在2几秒钟,它将显示我的主UINavigationController并且仅在启动屏幕上冻结时不起作用

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)
    }
}

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)

}

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. 您应该使用模仿默认初始屏幕图像的布局创建自定义Splash View Controller ,执行自定义动画(如果有),然后推送/显示下一个View Controller(在主线程上),或者根据应用需求执行任何操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM