2013-02-20 124 views
2

嗨我已經設計了一個XIB使用AutoLayout constriants來顯示兩行按鈕,每行有三個按鈕,如截圖所示(我將按鈕放入紅UIViews後,我得到一個滿意的佈局):iOS 6.0 AutoLayout問題約束:子視圖旋轉時消失

Portrait Mode Autolayout

到目前爲止好,在縱向模式下如上圖所示的按鈕看起來很好。但是,當我旋轉橫向標題(藍色)和父視圖(灰色)調整大小並正確顯示,但紅色按鈕視圖正好消失(見下文)。

enter image description here

什麼是設置約束上得到這個工作的權利的最佳途徑?我遵循Ray Wenderlich教程,並使用了他在示例中使用的相同編輯器\ Pin]垂直間距和編輯器\ Pin \ Horizo​​ntal間距: Ray Wenderlich tutorial

我也收到了很多約束錯誤,如下所示:

 Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x859abe0 UIView:0x85a8fb0.height == UIView:0x85a8e60.height>", 
    "<NSLayoutConstraint:0x859ab60 V:[UIView:0x85a8fb0]-(114)-| (Names: '|':UIView:0x85a8170)>", 
    "<NSLayoutConstraint:0x859ab20 V:|-(424)-[UIView:0x85a8fb0] (Names: '|':UIView:0x85a8170)>", 
    "<NSLayoutConstraint:0x85a3430 V:|-(150)-[UIView:0x85a8170] (Names: '|':UIView:0x85a8da0)>", 
    "<NSLayoutConstraint:0x85a33b0 V:[UIView:0x85a8170]-(NSSpace(20))-| (Names: '|':UIView:0x85a8da0)>", 
    "<NSAutoresizingMaskLayoutConstraint:0x75ac610 h=--& v=--& V:[UIView:0x85a8da0(704)]>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x859ab60 V:[UIView:0x85a8fb0]-(114)-| (Names: '|':UIView:0x85a8170)> 

Break on objc_exception_throw to catch this in the debugger. 
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 

我在我的智慧結束與此,所以從這個博學羣的任何幫助將不勝感激......!

+0

我有一個類似的問題,但完全沒有日誌。組織者中唯一提及的是這次事故。我如何在日誌中啓用它們? – 2013-06-02 18:53:16

+0

當然,我以編程方式處理該問題。 – 2013-06-02 18:59:36

回答

2

該錯誤意味着您有衝突的約束。試着讓它工作一行。

  1. 引腳與垂直間距爲藍色標題框
  2. 引腳每個紅色框具有前導空間左側紅色框的SuperView
  3. 引腳後面帶有一個空格右紅色框的SuperView
  4. 設置水平間距爲中心的紅色框
  5. 的左側和右側固定高度
  6. 選擇所有三個紅色框和(同樣寬度),將其設置爲具有相等的寬度
  7. 刪除由IB添加的任何無關限制
  8. 在設備上測試。 (我有模擬風景/人像)在界面生成器有時改變約束。 9它應該看起來像附加的圖像enter image description here
+0

非常感謝您抽出寶貴時間回覆併爲您精心佈置的答案。我會試試看,看看它是否解決了這個問題... – CoolDocMan 2013-02-20 22:54:29