[英]UINavigationController buttons disappear when layoutIfNeeded before modal presentation
Odd thing I am noticing: 我注意到的奇怪的事情:
let navController = UINavigationController(rootViewController: myRootViewController)
navController.view.layoutIfNeeded()
present(navController, animated: true, completion: nil)
In above code I am seeing the navigation controller bar button not showing when I add the layoutIfNeeded() 在上面的代码中,当我添加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.
当我添加layoutIfNeeded时,它会在呈现之前进行视图布局,从而解决了我原来的问题。
尝试将navController.view.layoutIfNeeded()扔到要显示的视图控制器的viewDidAppear:/ viewWillAppear:中,它应该对其进行修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.