translatesAutoresizingMaskIntoConstraints and IB

4
在 UIView.h 文件中,你可以读到以下内容:
/* by default, the autoresizing mask on a view gives rise to constraints 
   that fully determine the view's position.  Any constraints you set on 
   the view are likely to conflict with autoresizing constraints, 
   so you must turn off this property first. IB will turn it off for you.
 */
- (BOOL)translatesAutoresizingMaskIntoConstraints NS_AVAILABLE_IOS(6_0); // Default YES

因此,这意味着当您从xib创建一个UIView时,translatesAutoresizingMaskIntoConstraints应该设置为NO

然而,当我使用[[UINib nibWithNibName:nibName bundle:[NSBundle mainBundle]] instantiateWithOwner:self options:nil]从xib创建视图时,translatesAutoresizingMaskIntoConstraints被设置为YES

有任何想法吗?


如果在nib中设置了AutoLauOut的勾选标记,则会设置translatesAutoresizingMaskIntoConstraints。 - Sunny Shah
我的xib文件中的复选框“使用自动布局”已经被选中。 - MartinMoizard
@MartinMoizard,你找到答案了吗? - Blaz
@courteous - 不,仍然是个谜! - MartinMoizard
1个回答

2

事实证明这已经是苹果的漏洞报告中的一个错误。它将在未来的版本中修复。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接