NSLayoutConstraint conflict. UIView-Encapsulated-Layout-Height

| | August 18, 2015

I am having some problem with autoLayout. Particularly in iOS8.

I have already read the net and found similar issues when usingUITableViewCell.
But here I am not usingUITableViewCell and have noUITableView at all.

When it happens I only have aADBannerView and aUIWebView to deal with.

I get the following message in the Xcode debugger:

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) 
(
    "<NSLayoutConstraint:0x14e256f0 'UIView-Encapsulated-Layout-Height' V:[UIView:0x14e6c870(568)]>",
    "<NSLayoutConstraint:0x14d9b320 V:[ADBannerView:0x14d40c30(50)]>",
    "<NSLayoutConstraint:0x14d97b00 V:|-(20)-[ADBannerView:0x14d40c30]   (Names: '|':UIView:0x14e6c870 )>",
    "<NSLayoutConstraint:0x14d34880 ADBannerView:0x14d40c30.bottom == UIView:0x14e6c870.bottom>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x14d34880 ADBannerView:0x14d40c30.bottom == UIView:0x14e6c870.bottom>

First thing I want to say as a comment. I have not idea where the first constraint (UIView-Encapsulated-Layout-Height) is coming from.
Second thing; I added one constraint (though there are already too many), to enforce the height of theADBannerView, that fixed a display problem.
But I still get the message (as I expected).

If I do not add the constraint to enforce the height of theADBannerView. The background of the display becomes white and I fire iAd wherever I tap. A bit like if the height of theADBannerView was filling the whole display.

Any suggestion to solve this?

Of course I have not forgotten:

[adBanner setTranslatesAutoresizingMaskIntoConstraints:NO];

Please let me know if anyone has an idea on what is going on.

One Response to “NSLayoutConstraint conflict. UIView-Encapsulated-Layout-Height”

  1. Reading your constraints:

    "<NSLayoutConstraint:0x14d9b320 V:[ADBannerView:0x14d40c30(50)]>"
    

    ADBannerView has a height of 50 pixels

    "<NSLayoutConstraint:0x14d97b00 V:|-(20)-[ADBannerView:0x14d40c30]   (Names: '|':UIView:0x14e6c870 )>"
    

    ADBannerView is pinned to the top of the View with a margin of 20
    pixels

    <NSLayoutConstraint:0x14d34880 ADBannerView:0x14d40c30.bottom == UIView:0x14e6c870.bottom>
    

    You have pinned the bottom of the ADBannerView to the bottom of the
    UIView.

    "<NSLayoutConstraint:0x14e256f0 'UIView-Encapsulated-Layout-Height' V:[UIView:0x14e6c870(568)]>"
    

    The current View has a height of 568 pixels.

    Now this is conflicting with the height of 50 pixels you have assigned to the ADBannerView and the AdBannerView being pinned 20 pixels from the Top of the UIView.

    Either the height of the ADBannerView needs to be broken, or the pinning of the bottom, since both constraints cannot be satisfied…

    Unpin the AdBannerView from the bottom of the UIView to address this

Leave a Reply