Padding wrong when presenting second modal navigation controller on iOS 13

自闭症网瘾萝莉.ら 提交于 2020-01-25 06:49:14

问题


On iOS 13, when presenting a second modal view controller over a first one, the padding is incorrect on the button bar items. In particular, the right margin disappears.

How should this be fixed?


回答1:


This behavior is due to a bug in iOS 13. It can be fixed by calling setNeedsLayout on the Navigation Bar.

Swift example:

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

Objective-C example:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    // Fix navigation item placement on iOS 13: https://forums.developer.apple.com/thread/121861
    if (@available(iOS 13.0, *)) {
        [self.navigationController.navigationBar setNeedsLayout];
    }
}

Credits: Solution borrowed from this thread on the Apple Developer Form.



来源:https://stackoverflow.com/questions/59842299/padding-wrong-when-presenting-second-modal-navigation-controller-on-ios-13

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!