2017-10-13 78 views
3

我们开始使用Xcode 8.3开展我们的项目工作,直到iOS 10时才开始工作,但是当我们在iOS 11中运行相同的应用程序时,后退按钮没有像您预期的那样按照预期对齐下面后退按钮在iOS 11中没有正确分配

iOS 11 screenshot

但随着iOS的10其图像正确对齐

iOS 10 Screenshot

而这正是我们越来越

布局约束错误
(
"<NSLayoutConstraint:0x600000288200 _UIModernBarButton:0x7f7ef5c87f10.bottom == UILayoutGuide:0x6000005a0380'UIViewLayoutMarginsGuide'.bottom + 64.5 (active)>", 
"<NSLayoutConstraint:0x600000287f30 V:[_UIModernBarButton:0x7f7ef5c87f10]-(>=0)-| (active, names: '|':_UIButtonBarButton:0x7f7ef5c86e60)>", 
"<NSLayoutConstraint:0x600000282030 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x6000005a0380'UIViewLayoutMarginsGuide']-(16)-| (active, names: '|':_UIButtonBarButton:0x7f7ef5c86e60)>" 

回答

3

对我来说,那是因为我使用一些技巧,如下面隐藏标题

UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -1000), for: .default) 

我们不应该这样做,它不会在iOS上11工作,将触发大量自动布局问题像你发布。因此,检查您是否有后退按钮上的appearance

如果你真的想隐藏后退按钮的文字,你应该做的https://stackoverflow.com/a/46889050/1418457

1
UINavigationBar.appearance().backIndicatorImage = image.withRenderingMode(.alwaysOriginal) 
UINavigationBar.appearance().backIndicatorTransitionMaskImage = image.withRenderingMode(.alwaysOriginal) 

    if #available(iOS 11, *) { 
     UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.clear], for: .normal) 
     UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.clear], for: .highlighted) 
    } else { 
     UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffset(horizontal: -60, vertical: -60), for: .default) 
    } 
消除对之前的iOS设备11的其他条件时,
+1

,仍然,此代码的工作。所以我可以知道什么是重要的,否则条件? – g212gs

+0

对于小于ios 11 –

+0

是的,我从上面的代码了解,但是当我删除其他代码,仍然iOS 10设备看起来正确的用户界面。 – g212gs