【发布时间】:2014-05-20 14:41:57
【问题描述】:
我有一个关于自动布局世界的新问题,我可以将问题总结为以下步骤:
1- 我的情节提要只有一个场景包含 UIImageView 。
2- 我转到 viewcontroller.m 文件并添加如下代码的手动约束
[self.bgImageView setTranslatesAutoresizingMaskIntoConstraints:NO];
NSLayoutConstraint *horizentalSpaceConstraint = [NSLayoutConstraint constraintWithItem:self.bgImageView
attribute:NSLayoutAttributeTrailing
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeBottom
multiplier:1.0
constant:0.0];
[self.view addConstraint:horizentalSpaceConstraint];
结果:
约束没有影响 UIImageView 的 IBoutlet,但是如果我从 viewcontroller.m 文件中的硬编码添加 UIImageView 它可以工作,你能帮我发现这个问题吗?
【问题讨论】:
-
你有没有在 self.view 中添加过这个约束?
-
是的,我已经像上面的代码一样添加了它
标签: ios nslayoutconstraint autolayout flkautolayout