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

Autolayout warnings


  • Subject: Autolayout warnings
  • From: Doug Hill <email@hidden>
  • Date: Wed, 14 Dec 2016 14:19:52 -0800

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)toggleCommentsVisibility:(id)sender
{
	self.commentsAreHidden ? [self showComments:self] : [self hideComments:self];
}

- (IBAction)showComments:(id)sender
{
	self.showCommentsConstraint.active = YES;
	self.hideCommentsContainerConstraint.active = NO;

	self.commentsAreHidden = NO;
}

- (IBAction)hideComments:(id)sender
{
	self.showCommentsConstraint.active = NO;
	self.hideCommentsContainerConstraint.active = YES;

	self.commentsAreHidden = YES;
}

When I call showComments, I get the following warning in the console:

=====

Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
	(1) look at each constraint and try to figure out which you don't expect;
	(2) find the code that added the unwanted constraint or constraints and fix it.
(
    "<NSLayoutConstraint:0x7f91426a3ef0 'CommentContainerProportionalWidth' UIView:0x7f91426d9db0.width == 0.33*UIView:0x7f91426def30.width>",
    "<NSLayoutConstraint:0x7f91426c91e0 'Hide Comments Constraint' H:[UIView:0x7f91426d7f00]-(0)-[UIView:0x7f91426d9db0]>",
    "<NSLayoutConstraint:0x7f91426e2990 'ShowComments' UIView:0x7f91426d9db0.trailing == UIView:0x7f91426d7f00.trailing>",
    "<NSLayoutConstraint:0x7f91427e43c0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f91426def30(768)]>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f91426c91e0 'Hide Comments Constraint' H:[UIView:0x7f91426d7f00]-(0)-[UIView:0x7f91426d9db0]>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.

=====

This is puzzling because IB doesn't give me any autolayout errors/warning when I manually activate/deactivate these constraints. Also, I don't get this runtime warning when calling hideComments, only the 'show' case. Finally, things actually work at runtime because it's nice enough to "break" the constraint that I deactivated in code. But I would like to not have these warnings.

Any ideas on what's going on how I might go about debugging this?

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


  • Follow-Ups:
    • Re: Autolayout warnings
      • From: "Gary L. Wade" <email@hidden>
    • Re: Autolayout warnings
      • From: Ken Thomases <email@hidden>
    • Re: Autolayout warnings
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Users default alert sound
  • Next by Date: Re: Autolayout warnings
  • Previous by thread: Re: Users default alert sound
  • Next by thread: Re: Autolayout warnings
  • Index(es):
    • Date
    • Thread