iOS 6.0 AutoLayout问题约束:子视图旋转时消失

iOS 6.0 AutoLayout问题约束:子视图旋转时消失

问题描述:

嗨我已经设计了一个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

该错误意味着您有冲突的约束。试着让它工作一行。

  1. 引脚与垂直间距为蓝色标题框
  2. 引脚每个红色框具有前导空间左侧红色框的SuperView
  3. 引脚后面带有一个空格右红色框的SuperView
  4. 设置水平间距为中心的红色框
  5. 的左侧和右侧固定高度
  6. 选择所有三个红色框和(同样宽度),将其设置为具有相等的宽度
  7. 删除由IB添加的任何无关限制
  8. 在设备上测试。 (我有模拟风景/人像)在界面生成器有时改变约束。 9它应该看起来像附加的图像enter image description here
+0

非常感谢您抽出宝贵时间回复并为您精心布置的答案。我会试试看,看看它是否解决了这个问题... – CoolDocMan 2013-02-20 22:54:29