• 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: Autolayout warnings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Autolayout warnings


  • Subject: Re: Autolayout warnings
  • From: "Gary L. Wade" <email@hidden>
  • Date: Wed, 14 Dec 2016 17:21:32 -0800

In case it helps with your future animatable design, my particular app has a layout kind of like this:

——
|     | (8 points separation)Title (could be long)
|     | (8 points separation)Subtitle (could be long)
——

and I used something like this in viewDidLoad to preserve the values before I had any data:

-(void)viewDidLoad
{
	self.iconIndicatorWidthOriginalConstant =
		self.iconIndicatorWidth.constant;
	self.iconTitleLabelLeadingOriginalConstant =
		self.iconTitleLabelLeading.constant;
	self.iconSubtitleLabelLeadingOriginalConstant =
		self.iconSubtitleLabelLeading.constant;

	self.iconIndicatorWidth.constant = 0;
}

and I used something like this when I knew whether or not I wanted to show the icon indicator (the box to the left of the title and subtitle):

-(void)updateUI:(BOOL )showIconIndicator
{
	CGFloat	newIconIndicatorWidthConstant;
	CGFloat	newIconTitleLabelLeadingConstant;
	CGFloat	newIconSubtitleLabelLeadingConstant;

	if (showIconIndicator)
	{
		newIconIndicatorWidthConstant =
			self.iconIndicatorWidthOriginalConstant;
		newIconTitleLabelLeadingConstant =
			self.iconTitleLabelLeadingOriginalConstant +
			self.iconIndicatorWidthOriginalConstant + 8;
		newIconSubtitleLabelLeadingConstant =
			self.iconSubtitleLabelLeadingOriginalConstant +
			self.iconIndicatorWidthOriginalConstant + 8;
	}
	else
	{
		newIconIndicatorWidthConstant = 0;
		newIconTitleLabelLeadingConstant =
			self.iconTitleLabelLeadingOriginalConstant;
		newIconSubtitleLabelLeadingConstant =
			self.iconSubtitleLabelLeadingOriginalConstant;
	}

	if (newIconIndicatorWidthConstant != self.iconIndicatorWidth.constant)
	{
		[self.iconIndicator.superview layoutIfNeeded];
		[UIView animateWithDuration:0.3 animations:
		^{
			self.iconIndicatorWidth.constant =
				newIconIndicatorWidthConstant;
			self.iconTitleLabelLeading.constant =
				newIconTitleLabelLeadingConstant;
			self.iconSubtitleLabelLeading.constant =
				newIconSubtitleLabelLeadingConstant;

			[self.iconIndicator.superview layoutIfNeeded];
		}];
	}
}

--
Gary L. Wade
http://www.garywade.com/ <http://www.garywade.com/>
> On Dec 14, 2016, at 3:39 PM, Doug Hill <email@hidden> wrote:
>
> Great, more good stuff to know!
>
> However, trying this out I see that some views animate and others don't (just jump into place). I guess I'll look into a more animatable design.
>
> Doug Hill
>
>> On Dec 14, 2016, at 3:24 PM, Ken Thomases <email@hidden> wrote:
>>
>> On Dec 14, 2016, at 5:15 PM, Doug Hill <email@hidden> wrote:
>>>
>>> Ok, this is more good information to keep in mind when designing autolayout constraints. Given that my design isn't animatable, it's back to the autolayout drawing board. Again.
>>
>> I think it works to animate a change of constraints if you do the -layoutIfNeeded on the window within the animation context.  It's technically animating the frame changes rather than the constraints, which can transition through some different states and even temporarily violate constraints, but for this case it should work.
>>
>> Regards,
>> Ken
>>
>

_______________________________________________

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


References: 
 >Autolayout warnings (From: Doug Hill <email@hidden>)
 >Re: Autolayout warnings (From: "Gary L. Wade" <email@hidden>)
 >Re: Autolayout warnings (From: Doug Hill <email@hidden>)
 >Re: Autolayout warnings (From: "Gary L. Wade" <email@hidden>)
 >Re: Autolayout warnings (From: Doug Hill <email@hidden>)
 >Re: Autolayout warnings (From: Ken Thomases <email@hidden>)
 >Re: Autolayout warnings (From: Doug Hill <email@hidden>)

  • Prev by Date: Re: Users default alert sound
  • Next by Date: Re: Control default color inconsistencies
  • Previous by thread: Re: Autolayout warnings
  • Next by thread: Requires High Performance Graphic Card - Why?
  • Index(es):
    • Date
    • Thread