我正在努力实现以下目标:
我的xib中有2个视图,需要使边缘(两侧和顶部)保持20像素
需要调整大小的2个视图的大小不同
它们必须相隔20像素
它们的宽度需要相对于父视图的宽度保持不变
我阅读了有关执行此操作的教程,但是它的工作原理是,它需要两个视图具有相同的宽度和Widths equally的销钉,而我不希望这样做。
这是我尝试过的:
向左视图添加前导空间约束为20像素
向左视图添加顶部空间限制为20像素
向右视图添加顶部空间限制为20像素
向右视图添加尾随空间约束为20像素
将两个视图的水平间距约束添加为20像素
我遇到的问题是,左视图没有调整大小,右视图填充了空间以保持20像素的水平空间。
有没有办法让我两个视图都可以按比例填充它们应该填充的空间?
这是我的布局和约束的屏幕截图:
谢谢!
编辑
尝试旋转设备时收到以下警告:
2012-10-11 08:59:00.435 AutolayoutTest[35672:c07] 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)
(
"<0x8a6b2b0 h:>",0x8a6b2b0>
"<0x8a68ad0 h:>",0x8a68ad0>
"<0x8a6ba40 h:>",0x8a6ba40>
"<0x8a6ba00 h:>",0x8a6ba00>
"<0x8a6b940 h:>",0x8a6b940>
"<0x7199aa0 h="--&" v="--&" v:>"0x7199aa0>
)
Will attempt to recover by breaking constraint