ios - 更改 UILabel 文本不触发自动布局

标签 ios autolayout

我在 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/

相关文章:

ios - UIScrollView 动态高度内容(自动布局)未填满整个空间

ios - 如何设置尾随 Margin = Stackview.trailing

ios - 可调整大小然后可滚动的 UITextView,如 Telegram

ios - Swift - 如何使用偏移选项将 UNIX 时间转换为工作日?

ios - 如何根据 dp(不是点数)在 iOS 中设置 UILabel 字体大小,就像只有自动布局的 android 一样

iOS 8 自动布局问题

ios - 在更新 TableView 时,如何使用搜索栏对 NSFetchedResults 数据进行排序,而不会在 fetchedRC.performFetch() 上崩溃?更新

ios - 是否可以在 iPad Split View Controller 中插入标题?

iOS Core Data dispatch_async 后台排队崩溃

ios - AVPlayerController : Full screen Autolayout issues