在 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
。
有任何想法吗?