进行更改UILabel文本不会触发自动布局 [英] make change UILabel text not trigger auto layout

查看:69
本文介绍了进行更改UILabel文本不会触发自动布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在情节提要中有一个视图控制器,并在控制器中将UILabel和ui集合视图组合在一起.但是,每次更改UILabel文本时,它将触发自动布局,这表明我得到了视图将进行布局和视图进行布局的事件.我不想更改文本来触发自动布局.但是当我使用self.XCategoryLabel.translatesAutoresizingMaskIntoConstraints = NO;

I have a view controller in storyboard, and combining UILabel and ui collection view together in the controller. However every time I change the UILabel text, it will trigger auto layout, which shows I got view will layout and view did layout events. I don't want changing text to trigger auto layout. But When I use self.XCategoryLabel.translatesAutoresizingMaskIntoConstraints = NO;

它不起作用.

如何使UILabel文本更改不会触发自动布局?我确实在此控制器中使用了自动布局,但我不想让标签触发它.

How can I make UILabel text changing not trigger auto layout? I do use auto layout in this controller, but I DONT want the label to trigger it.

推荐答案

我在情节提要中添加了一个视图,并为其添加了约束.然后,通过代码将UILabel添加到该视图中,然后 NOT Label.translatesAutoresizingMaskIntoConstraints设置为NO.

I add a view in Storyboard, and add constraint to it. Then I add the UILabel into this view by code, and NOT setting Label.translatesAutoresizingMaskIntoConstraints to NO.

然后它将不会触发viewDidLayout和viewWillLayout.

Then It will not trigger viewDidLayout and viewWillLayout.

这篇关于进行更改UILabel文本不会触发自动布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆