ios - iOS 13 中第二个 View Controller 的导航栏按钮对齐错误

标签 ios swift navigationbar ios13 uinavigationitem

我正在使用 Storyboard添加一个按钮,如下图所示:

enter image description here

从第一个 Controller 呈现到第二个 Controller 时,导航栏按钮对齐显示不正确。

enter image description here

不知道是iOS 13的问题还是什么。

最佳答案

要解决此问题,您需要在 viewWillAppear 方法中手动调用 setNeedLayout,如下所述:

override func viewWillAppear(_ animated: Bool) {
     super.viewWillAppear(animated)
     if #available(iOS 13.0, *) {
          navigationController?.navigationBar.setNeedsLayout()
     }
} 

关于ios - iOS 13 中第二个 View Controller 的导航栏按钮对齐错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58542389/

相关文章:

ios - UiSlider 应该每秒在 UITableviewCell 内更新

ios - 从 Parse.com 中的指针检索 pfobject 数据的问题

ios - CGContext 中的椭圆径向渐变?

html - 导航栏内的文本在其他屏幕尺寸上自动移至右侧

iphone - 切换 MKMapView 显示语言

ios - 时间从 12 小时格式转换为 24 小时格式

ios - 从 UIViewController 导航到 SwiftUI View

swift - 如何以编程方式使标签更大?

jquery - 粘性导航栏跳到顶部

html - 左右浮动两个元素并垂直居中 UL?