I have a custom UIView with several sub Layers. One is a CATextLayer. I setup the layers in the view's LayoutSubviews method. When I subsequently set the text for the CATextLayer, my custom view's layoutSubviews method gets called, causing me pain. Why does this happen?
Asked
Active
Viewed 190 times
0
-
See Runtime Interaction Models @ http://developer.apple.com/library/ios/#documentation/windowsviews/conceptual/viewpg_iphoneos/WindowsandViews/WindowsandViews.html#//apple_ref/doc/uid/TP40009503-CH2-SW42 – bryanmac Apr 18 '13 at 11:59
-
Does the geometry of CATextLayer change when you set text? If so, the rules say layoutSubviews would get called ... – bryanmac Apr 18 '13 at 12:02
-
@bryanmac - thanks for your comments. I did read the docs you mentioned, and the quote "If the geometry of a view changed for any reason, UIKit updates its subviews..." makes sense. But.. I'm only changing the geometry of a "sub-Layer", which I would not really expect to trigger a "layoutSubview" call to the containing view. I'm missing the link that explains the mechanism which triggers a view layout when a sub-Layer changes. – Greycon Apr 18 '13 at 14:01
-
I would be concerned if when I fundamentally changed a sublayer the parent view didn't do the layoutSubviews. However, couldn't you just set a flag in your class when you first layout your subviews and set the text for the CATextLayer to ignore the next call to layoutSubviews? Then it wouldn't mess you up to have it called. – HalR Apr 19 '13 at 17:19