I have the following code in ViewControllerA
let layout = UICollectionViewFlowLayout()
let controller = ViewControllerB (collectionViewLayout: layout)
controller.contentData = self.users_cities[indexPath.row].content
self.navigationController?.pushViewController(controller, animated: true)
Now when let controller = ViewControllerB (collectionViewLayout: layout)
is called, the viewDidLoad
method of ViewControllerB
is executed and the UI is setup for ViewControllerB
. The problem is that this makes the UI of ViewControllerA
freeze for a few seconds before ViewControllerB
is pushed. Is there a different way of doing this in order to avoid this problem? The natural solution would be to run that on the background thread, but as far as I know, you shouldn't setup views on the background thread.