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)

        }

    }

    

    }

   
Answered by Claude31 in 697903022

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.

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

Accepted Answer

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.

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.

Change view controller automatically doesn't work
 
 
Q