简体   繁体   中英

How to move to another page directly without click a button in Swift

How can move to another page directly without click a button in Swift.

Like when you open a Twitter you see the first page it's a Twitter logo then directly move to timeline page. How to create it?

That is the launch screen. when you open the app from the killed state then it's launch screen will be showing first then after view controller which you show first time on app launch. You can add a launch screen via two methods.

  1. You need to add a launch image in assets

  2. Use launchScreen storyboard.

Check out these tutorials

https://useyourloaf.com/blog/using-a-launch-screen-storyboard/

https://www.appcoda.com/how-to-add-splash-screen-in-your-ios-app/

If you want to move to another screen after some duration, I suggest you add a timer and once the timer is fired perform a segue:

  1. Add a timer:

_ = Timer.scheduledTimer(timeInterval: 2.0, target: self, selector: #selector(moveToNextView), userInfo: nil, repeats: false)

  1. Perform a segue once the timer is fired:

@objc func moveToNextView() { self.performSegue(withIdentifier: "segueId", sender: nil) }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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