Vlad Vlad - 1 year ago 66
iOS Question

UINavigationController buttons disappear when layoutIfNeeded before modal presentation

Odd thing I am noticing:

let navController = UINavigationController(rootViewController: myRootViewController)
present(navController, animated: true, completion: nil)

In above code I am seeing the navigation controller bar button not showing when I add the layoutIfNeeded()

The reason I am trying to add this is I am finding the root view controller's view lays itself out while the modal presentation is happening. When I add the layoutIfNeeded it does the view layout before presenting which fixes my original problem.

Answer Source

Try throwing navController.view.layoutIfNeeded() in the viewDidAppear:/viewWillAppear: of the view controller you are presenting and it should fix it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download