3
votes

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;

It does not work.

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.

1
Why don't you want the label to trigger it? Is the laying out doing something to your collection view? - rdelmar
I have some touch events with another view, enabling user to pan and drag, and when using this label, every time I update the dataSource for UICollectionView, I will change the label as well. However if the label triggers auto layout, the touch events will break, not smooth - Wingzero
Well, I don't think it's possible when using auto layout to not have the label trigger those methods when you set the string. How are you doing your pan? Are you moving the view using constraints or setting frames? Is that view using auto layout? - rdelmar
I use auto layout for the skeleton views, but some views are created by code inside the skeleton views. when user drag or pan, the data is changing, so it will update you very smooth. However If I use this label, it will trigger the view will layout and view did layout events, so it will interrupt the gesture. I am thinking if I add this label inside a view will help? - Wingzero
I don't know if that will help. Go ahead and try it (but I'm skeptical that it will work). You didn't answer my other question. Are you moving your skeleton view by modifying constraints or setting new frames? - rdelmar

1 Answers

3
votes

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.

Then It will not trigger viewDidLayout and viewWillLayout.