How do I perform an auto-segue in Xcode 6 using Swift?

后端 未结 4 1757
灰色年华
灰色年华 2020-12-03 08:49

I wish to auto-segue from the main viewController to a second view controller after a set period of time after an app loads.

How do I do this?

Do I need to

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-03 09:25

    You can use this snippet of code:

    let delay = 1 // Seconds
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(delay * NSEC_PER_SEC)), dispatch_get_main_queue()) {
        self.launchMainUI()
        return
    }
    

    which performs the launchMainUI method after delay seconds. Replace it with your own implementation, where you instantiate your view controller and present it, or simply invoke a segue.

提交回复
热议问题