Note that there are some explanatory texts on larger screens.

plurals
  1. POAuto layout issue
    primarykey
    data
    text
    <p>I have the following auto layout constraints on the root view of a view controller : </p> <pre><code>(lldb) po [superview constraints] &lt;__NSArrayM 0x9e65ba0&gt;( &lt;NSLayoutConstraint:0x9e67d10 H:[HeaderView:0x9e6a1b0]-(0)-| (Names: '|':UIView:0x9e69040 )&gt;, &lt;NSLayoutConstraint:0x9e67ce0 H:|-(0)-[HeaderView:0x9e6a1b0] (Names: '|':UIView:0x9e69040 )&gt;, &lt;NSLayoutConstraint:0x9e67cb0 V:|-(0)-[HeaderView:0x9e6a1b0] (Names: '|':UIView:0x9e69040 )&gt;, &lt;NSLayoutConstraint:0x9e67c80 H:|-(0)-[RadialGradientView:0x9e685c0] (Names: '|':UIView:0x9e69040 )&gt;, &lt;NSLayoutConstraint:0x9e67c50 V:[RadialGradientView:0x9e685c0]-(0)-| (Names: '|':UIView:0x9e69040 )&gt;, &lt;NSLayoutConstraint:0x9e67c20 H:[RadialGradientView:0x9e685c0]-(0)-| (Names: '|':UIView:0x9e69040 )&gt;, &lt;NSLayoutConstraint:0x9e67bf0 V:[HeaderView:0x9e6a1b0]-(0)-[RadialGradientView:0x9e685c0]&gt;, &lt;NSLayoutConstraint:0x10c89830 HeaderView:0x9e6a1b0.height == UIView:0x9e69040.height + 35&gt; ) </code></pre> <p>And when I add the height constraint (the last one), I get an autolayout ambiguous layout error :</p> <pre><code>2013-10-16 16:18:43.121 Application[26038:a0b] 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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "&lt;NSLayoutConstraint:0xb016da0 V:|-(0)-[HeaderView:0xb0192a0] (Names: '|':UIView:0xb018130 )&gt;", "&lt;NSLayoutConstraint:0xb016d40 V:[RadialGradientView:0xb0176b0]-(0)-| (Names: '|':UIView:0xb018130 )&gt;", "&lt;NSLayoutConstraint:0xb016ce0 V:[HeaderView:0xb0192a0]-(0)-[RadialGradientView:0xb0176b0]&gt;", "&lt;NSLayoutConstraint:0xb00c3f0 HeaderView:0xb0192a0.height == UIView:0xb018130.height + 35&gt;" ) Will attempt to recover by breaking constraint &lt;NSLayoutConstraint:0xb016ce0 V:[HeaderView:0xb0192a0]-(0)-[RadialGradientView:0xb0176b0]&gt; Break on objc_exception_throw to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKit/UIView.h&gt; may also be helpful. </code></pre> <p>RadialGradientView is a subclass of UIView that is only overriding the drawRect: method. The HeaderView is also a subclass of UIView with the following code : </p> <pre><code>@implementation HeaderView { NSLayoutConstraint * heightConstraint; } static UINib * headerViewNib = nil; - (id)awakeAfterUsingCoder:(NSCoder *)aDecoder { if (![[self subviews] count]) { if (headerViewNib == nil) headerViewNib = [UINib frameworkNibWithNibName: @"HeaderView"]; SMDFHeaderView * headerView = [[headerViewNib instantiateWithOwner: nil options: nil] lastObject]; [headerView setTranslatesAutoresizingMaskIntoConstraints: NO]; [self removeConstraints: [self constraints]]; return headerView; } return self; } - (void)layoutSubviews { if (!heightConstraint) [self setNeedsUpdateConstraints]; [super layoutSubviews]; } - (void)updateConstraints { if (!heightConstraint) { UIView * superview = [self superview]; heightConstraint = [NSLayoutConstraint constraintWithItem: self attribute: NSLayoutAttributeHeight relatedBy: NSLayoutRelationEqual toItem: superview attribute:NSLayoutAttributeHeight multiplier: 1.0 constant: 35.0]; [superview addConstraint: heightConstraint]; } [super updateConstraints]; } /* Tried that, but it does not change anything. - (CGSize)intrinsicContentSize { return CGSizeMake([[super superview] frame].size.width, 35); }*/ @end </code></pre> <p>PS : The issue does not seems to be related to the nib replacement trick, even if i comment the awakeAfterUsingCoder method, it does the same thing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload