1

I have a UIViewController, call this ViewControllerB, which I am attempting to push from ViewControllerA. ViewControllerB has a ton of custom UI from libraries (calendar, segmented controls, etc), as well as a UIPageViewController with tableViews.

I noticed that there is a 1-3 second delay when I push ViewControllerB, and upon using time profiler, I am able to trace it to blockage of the main thread due to setting up these UI in viewDidLoad. So it appears that the app needs some time to set up UI before pushing the view controller.

What is the best way to set up a ton of UI but avoid blocking the main thread when pushing view controllers?

Josh O'Connor
  • 4,694
  • 7
  • 54
  • 98

1 Answers1

4

There was too much layout going on in the initialization blocking the main thread. Only layout whats necessary in init, viewDidLoad, and viewWillAppear methods, and anything else do in viewDidAppear.

Josh O'Connor
  • 4,694
  • 7
  • 54
  • 98