• 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
Re: Move views relative to other view with Autolayout
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Move views relative to other view with Autolayout


  • Subject: Re: Move views relative to other view with Autolayout
  • From: Doug Hill <email@hidden>
  • Date: Thu, 10 Mar 2016 13:21:46 -0800

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 <email@hidden> wrote:
>
> On Mar 10, 2016, at 12:59 , Doug Hill <email@hidden <mailto:email@hidden>> 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 (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


  • Follow-Ups:
    • Re: Move views relative to other view with Autolayout
      • From: Ken Thomases <email@hidden>
References: 
 >Move views relative to other view with Autolayout (From: Doug Hill <email@hidden>)
 >Re: Move views relative to other view with Autolayout (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Move views relative to other view with Autolayout
  • Next by Date: Re: Move views relative to other view with Autolayout
  • Previous by thread: Re: Move views relative to other view with Autolayout
  • Next by thread: Re: Move views relative to other view with Autolayout
  • Index(es):
    • Date
    • Thread