Re: Constraints to keep 2 views same height not working
Re: Constraints to keep 2 views same height not working
- Subject: Re: Constraints to keep 2 views same height not working
- From: Steve Mills <email@hidden>
- Date: Wed, 25 Jan 2017 16:19:11 +0000 (GMT)
On Jan 24, 2017, at 04:25 PM, Wim Lewis <email@hidden> wrote:
On Jan 24, 2017, at 1:42 PM, Steve Mills <email@hidden> wrote:
This should be easy, but it's not working. There's even a sample in Apple's Auto Layout Guide that shows the same constraints that I'm using (although it's doing widths instead of heights).
You may have already checked for this, but: is "translates autoresize mask to constraints" turned on for any of the views? This trips me up pretty often. The constraints generated that way have a highish priority, so they might be quietly overriding your explicit constraints without causing any conflicts that would show in a log message.
In windowDidLoad I walked all subviews and the only ones with translatesAutoresizingMaskIntoConstraints turned on are the NSClipView and its NSTextView that are inside the NSScrollView, and the 2 NSScrollers.
Otherwise, maybe try [theWindow visualizeConstraints:[someView constraintsAffectingLayoutForOrientation:...]].
Thanks, I forgot about visualizeConstraints. It doesn't show anything wrong, and shows the constraints I'd expect on the 2 views in question. Clicking on first the NSScrollView's height constraint, then the NSTextField's height constraint looks correct to me:
2017-01-25 09:58:16.468 svnUp[36881:12545728] Clicked on overlapping visualized constraints: (
"<NSLayoutConstraint:0x618000094550 NSTextField:0x618000189da0.height == NSScrollView:0x6180001c0c30.height priority:750> (Actual Distance - pixels):76",
"<NSLayoutConstraint:0x618000094870 V:[NSScrollView:0x6180001c0c30(>=76)]> (Actual Distance - pixels):76"
)
2017-01-25 09:58:20.966 svnUp[36881:12545728] Clicked on visualized constraint: (
"<NSLayoutConstraint:0x618000094550 NSTextField:0x618000189da0.height == NSScrollView:0x6180001c0c30.height priority:750> (Actual Distance - pixels):76"
)
Oh! The problem is the stupid NSTextField. They're weird when it comes to their height, even though they can be a wrapped multi-line field. I tried different values in its Preferred Width, but it didn't make any difference in how it handles constraints. I wish they'd fix that. I ended up replacing the NSTextField with another NSTextView in the scroll view.
Sent from iCloud's ridiculous UI, so, sorry about the formatting
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden