草庐IT

ios - translatesAutoresizingMaskIntoConstraints 和 IB

coder 2023-09-29 原文

在 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] 创建 View 时,translatesAutoresizingMaskIntoConstraints设置为 YES

知道为什么吗?

最佳答案

事实证明这是一个已经在 Apple 的错误报告程序中提交的错误。它应该在未来的版本中修复。

关于ios - translatesAutoresizingMaskIntoConstraints 和 IB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23470857/

有关ios - translatesAutoresizingMaskIntoConstraints 和 IB的更多相关文章

随机推荐