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

Move views relative to other view with Autolayout


  • Subject: Move views relative to other view with Autolayout
  • From: Doug Hill <email@hidden>
  • Date: Thu, 10 Mar 2016 12:59:36 -0800

I’m trying to implement a side panel that moves into place horizontally and push content over when it is shown. 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.

Looking at the Googles, I see a number of cases where people try to handle this situation by doing one of the following:

• Creating another constraint from the first view to the superview margin. They then disable to first constraint to side view and and enable the alignment constraint to the superview margin.

• Manually change the value of the alignment constraint to the side view.

Neither seem all that satisfactory. I guess I’m wondering why the original alignment constraint doesn’t allow for dynamic changes to the view layout. Why won’t autolayout cause the views to layout again when views move?
FYI, I tried calling ‘updateConstraintsIfNeeded’ on all these view after changing the side view origin and this seems to have no effect.

I also checked Apple’s Autolayout programming guide and didn’t find anything that would answer this question. Thanks for any info/pointers about this.

Doug
_______________________________________________

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: Quincey Morris <email@hidden>
  • Prev by Date: Re: Thoughts on a line-at-a-time data-reading class
  • Next by Date: Re: Move views relative to other view with Autolayout
  • Previous by thread: Re: Thoughts on a line-at-a-time data-reading class
  • Next by thread: Re: Move views relative to other view with Autolayout
  • Index(es):
    • Date
    • Thread