Change view controller automatically doesn't work

In my app I've got moment where I use timer to go from one view controller to next view controller, and it doesn't work. Could somebody tell me what's wrong?




class fifthViewController: UIViewController {



    override func viewDidLoad() {

        super.viewDidLoad()

        

        let delay : Double = 2.0    // 2 seconds here

        DispatchQueue.main.asyncAfter(deadline: .now() + delay) {

            let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

            let IDKViewController = storyBoard.instantiateViewController(withIdentifier: "IDKview") as! IDKViewController

            self.present(IDKViewController, animated:true, completion:nil)

        }

    }

    

    }

   
  • You should answer the other post ; better than creating a new one for the same question.

  • Well sorry Claude, but I answered

  • It seems your answers to some posts are not visible yet. And don't forget to close the threads, that makes it much easier to understand it is solved.

Add a Comment

Accepted Reply

it doesn't work

That does not provide any useful information.

  • What do you get
  • Do you get error message?
  • Do you get a crash ?
  • what do you expect ?
  • Is it SwiftUI ? If so, show complete code

I tested in a project, it works as expected.

Are you sure you defined IDKview class in IB correctly ?

And please, answer the post here, not in a new one, and close previous posts if they are terminated.

  • Ok thank you very much, I will check all these things.

  • Claude can I get rid of identifier? Because I don't know if I did it as I should have done.

Add a Comment

Replies

it doesn't work

That does not provide any useful information.

  • What do you get
  • Do you get error message?
  • Do you get a crash ?
  • what do you expect ?
  • Is it SwiftUI ? If so, show complete code

I tested in a project, it works as expected.

Are you sure you defined IDKview class in IB correctly ?

And please, answer the post here, not in a new one, and close previous posts if they are terminated.

  • Ok thank you very much, I will check all these things.

  • Claude can I get rid of identifier? Because I don't know if I did it as I should have done.

Add a Comment