Re: Autolayout warnings
Re: Autolayout warnings
- Subject: Re: Autolayout warnings
- From: Doug Hill <email@hidden>
- Date: Wed, 14 Dec 2016 14:49:48 -0800
> On Dec 14, 2016, at 2:46 PM, Ken Thomases <email@hidden> wrote:
>
> On Dec 14, 2016, at 4:19 PM, Doug Hill <email@hidden> wrote:
>>
>> I'm seeing warnings in the console when I dynamically make autolayout constraints active/inactive at runtime.
>>
>> I have two constraints that align a container view leading or trailing edge with another view's edge. This is to move the container onscreen or offscreen. I have another view whose trailing edge aligns with the leading edge of the first container view so it moves with it as autolayout constraints change.
>>
>> At runtime, I make one of these constraints active and the other inactive, like so:
>
>> - (IBAction)showComments:(id)sender
>> {
>> self.showCommentsConstraint.active = YES;
>> self.hideCommentsContainerConstraint.active = NO;
>
> Swap the order of these. Always disable no-longer-applicable constraints before enabling newly-applicable constraints. The way you have it here, after the first line, you temporarily have constraints which conflict enabled. You fix that with the next line, but you've already gotten the warning by then.
Ding-Ding-Ding-Ding-Ding-Ding! We have a winner!
I went ahead and made this change and warnings are gone. Will keep the order of activation in mind for future coding.
Doug Hill
_______________________________________________
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