Unfortunately, we have an iOS 8 requirement so we can’t use stack views. I can see that people use multiple constraints when moving between different layouts. But what I don’t get is how there can be an alignment constraint that doesn’t cause a layout update when views move? How does autolayout decide to use the constraint when originally laying out the view but ignores it when the view layout changes? Apparently I don’t understand this very well but the docs don’t seem to go out of their way to describe this difference either.
Thanks. Doug Hill > On Mar 10, 2016, at 1:15 PM, Quincey Morris > <quinceymor...@rivergatesoftware.com> wrote: > > On Mar 10, 2016, at 12:59 , Doug Hill <cocoa...@breaqz.com > <mailto:cocoa...@breaqz.com>> wrote: >> >> I set up an auto layout constraint so that an another view is a fixed number >> of pixels from the side view. I then want to move the origin of the side >> view and have the other view move with it. >> >> If I set up an alignment constraint so trailing space from my first view to >> the side view is a fixed number of pixels. Let’s say 20 pixels. When I move >> the origin of the side view, the first view doesn’t keep the 20 pixel >> spacing. In fact does nothing. > > Isn’t the issue what constraints you’ve put on the side view? > > When using autolayout, you can’t “move the origin” of a view, except by > adjusting constraints programmatically. You have to come up with a set of > constraints that describes the relationship of the views in both > configuration (side view visible or not). You might be able to do this by > adding conflicting constraints to the first view (trailing to side view, > trailing to superview), then enable one constraint and disable the other. To > change configurations, toggle both enable properties and setNeedsLayout. > > The easy way to do this, of course, is to use a horizontal stack view > (NSStackView, UIStackView), since that handles hiding and showing of views > without explicit constraints. NSStackView has been around since OS X 10.9 but > real autolayout compatibility only came in 10.11, UIStackView has been around > since iOS 9.0. > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com