Auto-layout: What creates constraints named UIView-Encapsulated-Layout-Width & Height?
Based on a ton of observation I believe (but cannot know for certain) that the constraints named UIView-Encapsulated-Layout-Width
and UIView-Encapsulated-Layout-Height
are created by UICollectionView
and friends, and exist to enforce the size returned by the sizeForItemAtIndexPath
delegate method. I guess it's there to ensure that the UICollectionViewCell
set up by cellForItemAtIndexPath
ends up the size that it was told it would be.
Which answers my initial question here. A second question is why were the constraints unsatisfiable? The cell's intrinsic height should have been the same as UIView-Encapsulated-Layout-Height
. Again, I don't know for certain, but I suspect it was a rounding error (i.e. intrinsic height came to 200.1 pixels, the UIView-Encapsulated-Layout-Height
maybe rounded to 200. The fix I came up with was to just lower the priority of the relevant cell constraint to allow UIView-Encapsulated-Layout-Height
to have the last word.
iOS 8.3 'UIView-Encapsulated-Layout-Width' in Custom Keyboard
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)
(
"<NSAutoresizingMaskLayoutConstraint:0x15dd1da0 h=-&- v=-&- Keyboard:0x15db2b00.width == UIView:0x15da7b90.width - 320>",
"<NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>
It is telling you that it can't satisfy all constraints at once.
You have a constraint <NSAutoresizingMaskLayoutConstraint:0x15dd1da0 h=-&- v=-&- Keyboard:0x15db2b00.width == UIView:0x15da7b90.width - 320>
, which dictates the width of the keyboard equals the width of the UIView
at 0x15da7b90
minus 320 (check the debugger which one this is, I usually look at the GUI debugger if I know what UIView
s might be causing the problem).
The other conflicting constraint is <NSLayoutConstraint:0x15dd2520 'UIView-Encapsulated-Layout-Width' H:[UIView:0x15da7b90(0)]>
, which dictates the width of the UIView
at 0x15da7b90
(same one) to be 0. It cannot satisfy both this one and the one above, so it breaks this one.
I see that your first constraint is one of the type NSAutoresizingMaskLayoutConstraint
, so you can try to set setTranslatesAutoresizingMaskIntoConstraints
to false on your view, which will probably remove the first constraint, thus removing the conflict.
Other helpful documentation:
- Visual Format Language, the format that Xcode uses in the log, helps to know this language to debug them better.
- View Debugging in Xcode, helps to identify which views are where and at what address.
Related Topics
Nib But Didn't Get a Uitableview
Firebase Undefined Symbols for Architecture X86_64
Wkwebview Content Loaded Function Never Get Called
Combine Framework Serialize Async Operations
The Supportedinterfaceorientations Method Doesn't Override Any Method from Its Superclass
How to Convert a Nib-Based Project to a Storyboard-Based
Update the Constant Property of a Constraint Programmatically in Swift
Swift- Change Font on an HTML String That Has Its Own Styles
How Does Xcode Find Implicit Target Dependencies
Xcode 7.3.1 with iOS 10 Support
How to Set Primary Key in Swift for Realm Model
Alternative iOS Layouts for Portrait and Landscape Using Just One .Xib File
Save Image Data to SQLite Database in Iphone
Nsdata Won't Accept Valid Base64 Encoded String
Nscache Doesn't Work with All Images When Loading for the First Time
How to Use Keychain for Saving Password Like Generickeychain Sample Code