ios - UINavigationController 按钮在模式呈现之前 layoutIfNeeded 时消失

标签 ios swift uinavigationcontroller uikit

我注意到的奇怪的事情:

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

在上面的代码中,当我添加 layoutIfNeeded() 时,我看到导航 Controller 栏按钮没有显示

我尝试添加这个的原因是我发现 Root View Controller 的 View 在模态呈现发生时自行布局。当我添加 layoutIfNeeded 时,它会在呈现之前执行 View 布局,这解决了我原来的问题。

最佳答案

尝试在您呈现的 View Controller 的 viewDidAppear:/viewWillAppear: 中使用 navController.view.layoutIfNeeded(),它应该会修复它。

关于ios - UINavigationController 按钮在模式呈现之前 layoutIfNeeded 时消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40619900/

相关文章:

ios - 为什么我的可旋转轮控件有时会向错误的方向旋转?

ios - UIView 在显示键盘时出现,但在我开始键入时消失(快速)?

ios - 如何在 iOS、Swift 中搜索 iBeacons UUID,并扫描周围的所有 iBeacons

ios - 当用户点击 SwiftUI 中的列表行时如何显示警报

ios - 如何使 self.view 成为 View Controller 的全高(同时占据导航栏和状态栏的高度)

ios - PhoneGap 将图像下载到特定文件夹

ios - OpenGL ES 2.0 中的 GLPaint

ios - Swift 模态 self 变为 Nil

ios - PushViewController 之后 ViewController 不会显示在屏幕上,但它出现在 UI-Debugger 中

iphone - StackScrollView 与委托(delegate) ID MBProgressHUD 的问题