• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Autolayout: How to force calling [NSView baselineOffsetFromBottom] again?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: How do IB inspector fields relate to the actual objects?
  • Next by Date: Re: Round corners of borderless NSWindow without set it transparent
  • Previous by thread: Re: How do IB inspector fields relate to the actual objects?
  • Next by thread: Modal only to another window?
  • Index(es):
    • Date
    • Thread