Autolayout, SplitViews and Silencing Certain Invalid Constraint Warnings
Autolayout, SplitViews and Silencing Certain Invalid Constraint Warnings
- Subject: Autolayout, SplitViews and Silencing Certain Invalid Constraint Warnings
- From: Martin Pilkington <email@hidden>
- Date: Thu, 18 Aug 2011 16:50:31 +0100
Hey all,
I've got a problem with using Autolayout in a NIB containing a window which itself contains a split view. Now I've had no issue with adding views to a splitview that use constraints, or even using constraints to say how those views should fill the splitview's subviews. But I now want to use constraints in the window, as I'm adding something that is much easier to handle with constraints. Problem is this is causing huge issues.
My view hierarchy in this case is Window -> Split View -> Subview -> Content View (taken from another NIB loaded by a view controller). I have lots of constraints set up in these content views and they're normally fine. However, AppKit seems intent on setting the size of the Subview to (0,0). This causes all the internal constraints to break and Autolayout then has to go through each constraint, breaking them, until it reaches the autoresizing mask constraint added for the (0,0) size. When AppKit adds a sane value back in for the size, then the constraints work out fine so when the window loads the UI looks fine.
The problem is that while I could get away with that for release, I have breakpoints turned on for exceptions as well as NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints set to YES. So every time I launch the app I'm having to go through all these exceptions (which could be quite a few if the autoresizing constraint is the last in the list), and then put up with the visual debugging aid while the app is launched.
Is there anyway good to work around this? I've tried calling setTranslatesAutoresizingMaskIntoConstraints:NO on the Subview but that causes the splitview to just break completely. At the moment I'm considering just subclassing NSView and overriding setFrame: so it can never get that small, which I've had to do for a table view cell view which had the exact same problem. It's just frustrating having to do a nasty hack just to be able to use Autolayout and keep the ability to debug without pulling my hair out, especially as it seems to be AppKit causing the issue in the first place.
Thanks
Martin_______________________________________________
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