translatesAutoresizingMaskIntoConstraints和IB

时间:2014-05-05 11:00:43

标签: ios objective-c autolayout

在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

知道为什么吗?

1 个答案:

答案 0 :(得分:2)

事实证明,这是一个已经在Apple的bug报道中提交的错误。它应该在将来的版本中修复。