2017-10-13 104 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