Autolayout: How to force calling [NSView baselineOffsetFromBottom] again?
Autolayout: How to force calling [NSView baselineOffsetFromBottom] again?
- Subject: Autolayout: How to force calling [NSView baselineOffsetFromBottom] again?
- From: Manfred Schwind <email@hidden>
- Date: Wed, 29 Feb 2012 20:20:39 +0100
Hi,
I have a view hierarchy using Cocoa Autolayout (new in Lion) loaded from a nib.
After the nib is loaded, I do some additional configuration for some views (mostly in awakeFromNib). Specifically I have a NSTextField subclass and the additional configuration causes my custom baselineOffsetFromBottom implementation to return a different value. Problem: Cocoa only calls baselineOffsetFromBottom when initially loading the nib, but never calls it again! The value seems to be cached somehow by the Cocoa Autolayout system. So my custom NSTextField subclass with baseline autolayout constaints is not correctly aligned, because an outdated value is used.
How can I force Cocoa to re-read baselineOffsetFromBottom?
I tried calling setNeedsUpdateConstraints:YES, setNeedsLayout:YES and invalidateIntrinsicContentSize on my custom text field. I called layoutIfNeeded on the window. Nothing helps! baselineOffsetFromBottom is never called again and the layout is always done with the old outdated value.
I even tried setting a different font to the text field. That should normally "reset" the baseline offset and force re-calling baselineOffsetFromBottom, even in a plain "not subclassed" NSTextField, shouldn't it? But even that does not force re-calling baselineOffsetFromBottom; so this smells like a bug.
I put a breakpoint (and an NSLog) in my baselineOffsetFromBottom implementation, and I see that it is really called just once while initially loading the nib and I can't force it to be called again.
Any other ideas?
Is this a bug in Cocoa?
Regards,
Mani
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden