我在 Storyboard中有一个 View Controller ,并在 Controller 中将 UILabel 和 ui Collection View 组合在一起。然而,每次我更改 UILabel 文本时,它都会触发自动布局,这表明我获得了 View 将布局和 View 执行布局事件。我不想更改文本来触发自动布局。但是当我使用self.XCategoryLabel.translatesAutoresizingMaskIntoConstraints = NO;
时
它不起作用。
如何使 UILabel 文本更改不触发自动布局?我确实在此 Controller 中使用自动布局,但我不希望标签触发它。
最佳答案
我在 Storyboard 中添加一个 View ,并为其添加约束。然后,我通过代码将 UILabel 添加到此 View 中,并且不将 Label.translatesAutoresizingMaskIntoConstraints
设置为 NO
。
那么就不会触发viewDidLayout和viewWillLayout了。
关于ios - 更改 UILabel 文本不触发自动布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28423083/