如何正确设置此布局的约束?

时间:2013-03-16 22:16:59

标签: xcode user-interface constraints

我已经尝试了很长时间但是因为约束问题而不断崩溃......

如何设置此布局,以便在iPhone 3Gs,4和5以及iPad上运行?

_______TOP OF SCREEN________



Table View should attach to top of screen and with 5 pixels to the Label below
flexible in height so it works on iPhone 5 and 6


____________________________


Label with fixed distance to table View above and button below

____________________________

Button with fixed distance to Label above and fixed distance to bottom of screen

____________________________
      Bottom of screen

所以基本上所有的距离和高度都是固定的,除了桌子的高度,它应该填满屏幕顶部和标签之间可用的任何东西

每当我设置这样的约束时,我一直在使用iOS 6.1的iPhone 3上崩溃:

 2013-03-16 23:12:51.013 BMWhat Test[64196:907] Unable to simultaneously satisfy constraints.
    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) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x1d1f2d70 h=-&- v=-&- UIView:0x1d1aac20.height == UITransitionView:0x1d174220.height - 20>",
    "<NSLayoutConstraint:0x1d1c03b0 V:[UILabel:0x1c58f100(21)]>",
    "<NSLayoutConstraint:0x1d1ce780 V:[UITableView:0x1cbd9000(469)]>",
    "<NSLayoutConstraint:0x1c5aff30 V:[UIButton:0x1d1d1bb0(44)]>",
    "<NSLayoutConstraint:0x1d1c0030 V:|-(0)-[UITableView:0x1cbd9000]   (Names: '|':UIView:0x1d1aac20 )>",
    "<NSLayoutConstraint:0x1d1921d0 V:[UILabel:0x1c58f100]-(1)-[UIButton:0x1d1d1bb0]>",
    "<NSAutoresizingMaskLayoutConstraint:0x1c58e4d0 h=--- v=--- V:[UIWindow:0x1d002230(480)]>",
    "<NSLayoutConstraint:0x1d1cd6c0 V:[UITableView:0x1cbd9000]-(NSSpace(8))-[UILabel:0x1c58f100]>",
    "<NSLayoutConstraint:0x1d1ca370 V:[UIButton:0x1d1d1bb0]-(5)-|   (Names: '|':UIView:0x1d1aac20 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x1d172a90 h=--& v=-&- UITransitionView:0x1d174220.height == UIWindow:0x1d002230.height>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1d1ce780 V:[UITableView:0x1cbd9000(469)]>

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.

在模拟器iPhone Retina 4英寸iOS 6上运行正常。

2 个答案:

答案 0 :(得分:2)

仅在iOS 6中支持NSLayoutConstraint。

iPhone 3不支持iOS 6. 3Gs是最早的型号。

答案 1 :(得分:2)

问题是你在tableview上指定一个垂直约束,将其高度绑定到469 pt。由于您希望tableview的高度变得灵活,因此您不需要该约束。