0

I have two view controllers.

I made imageview (in the Gif file) in first VC. After 5seconds, I want page pass to second vc. First VC code is like this:

class LemonVC: UIViewController {

    @IBOutlet weak var LemonGif: UIImageView!
    override func viewDidLoad() {
        super.viewDidLoad()


        LemonGif.loadGif(name: "sufoo")

    //        DispatchQueue.main.asyncAfter(deadline: .now() + 
    .seconds(4), execute: {
    //
    //        })
        // Do any additional setup after loading the view.
    }

enter image description here

First VC name is LemonVC

Second VC name is SecondVC

2
  • 1
    I'd probably not start it in viewDidLoad, but might consider viewDidAppear for starters Commented Apr 19, 2018 at 11:11
  • I think the other command you're looking for is performSegue ... assuming you actually named the segue's between you view controllers Commented Apr 19, 2018 at 11:13

2 Answers 2

1

One possibility is to use a segue between the first and second controller to define a navigation path (drag from the "yellow" dot in the first controller onto the second controller. This example uses a show kind)

Segue

Make sure you give it an identifier name, you need this in your code.

I would probably use viewDidAppear over viewDidLoad, at least it means that the view has transitioned to the screen.

Then, all you need to do is use UIViewController#performSegue to execute the segue, which will present the next controller

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5), execute: {
        self.performSegue(withIdentifier: "skipTo", sender: self)
    })
}
Sign up to request clarification or add additional context in comments.

1 Comment

Glad it could help - just remember, there's always more then one way to skin a cat - this is just one way to do what you want ;)
0

Try this:

  DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5), execute: {
// go some where
// example
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
        let introRootVC = storyBoard.instantiateInitialViewController() // it's main controller, if you want to another create Story board ID 
        self.present(introRootVC!, animated: true, completion: nil)
})

You can change delay, seconds(5) <- here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.