What is a 'UIView-Encapsulated-Layout-Width' constraint?
I keep getting ‘Unable to simultaneously satisfy constraints’ exceptions (Xcode 5, iOS 7, both device and simulator), where one of the constraints in the list is something like this:
"<NSLayoutConstraint:0x165b23d0 'UIView-Encapsulated-Layout-Width' H:[StoryPlayerCell:0x165affc0(0)]>"
I did not set this constraint myself. It’s also not an
But where does it come from? And how can I get rid of it?
I have no idea.
And I can’t find anything about
'UIView-Encapsulated-Layout-Width' in the Apple’s documentation.
Even the Google search returns nothing at all.
PS: I’m using this cell in a
UICollectionView with a custom subclass of
UICollectionViewFlowLayout. Maybe the
'Encapsulated-Layout' part has something to do with this?
- iOS UICollectionView - default flow, fill rows from right to left
- Warning: UICollectionViewFlowLayout has cached frame mismatch for index path 'abc'
- UICollectionViewLayout layoutAttributesForElementsInRect and layoutAttributesForItemAtIndexPath
- UICollectionView display 3 items per row
- Auto Layout Collection view according to various screen sizes
- UICollectionView custom line separators
4 Solutions Collect From Internet About “What is a 'UIView-Encapsulated-Layout-Width' constraint?”
A quick and nice fix, is to assign
999 priority value to the custom constraints with high priority. The encapsulated & auto-generated constraints should dominate with higher priority than your constraints.
i played with the sample, i think these codes is causing the Autolayout exception.
CGFloat height = MAX(0, -y + maxY); line 79 in CSStickyHeaderFlowLayout.m.
if you use a static value for the height like 200, the exception won’t happen anymore. i can’t understand what exactly is UIView-Encapsulated-Layout, but seems like dynamically changing the UICollectionViewLayoutAttributes frame may cause that problem. in the sample project, it’s the height, in PO’s problem, i guess it’s the width. Maybe i can dig a little bit more into it, if you think that would be helpful
I can shed some light on the answer to the question. In my OS X app, I found such a mysterious constraint on the cell view of an NSTableView, (that is, an object which I had previously returned in the NSTableViewDelegate method -tableView:viewForTableColumn:row). I had also sent a setWidth:0.0 message to this same table column. Changing the parameter in that setWidth: from 0.0 to something else was reflected in the constant value of the mysterious constraint.
Conclusion: Constraints which log themselves with ‘UIView-Encapsulated-Layout-Width’ or ‘NSView-Encapsulated-Layout-Width’ are caused by setting the width of a table column, or something similar.
I found this with iOS 10 builds where I was using UITableViewCell subclasses as normal views not as table rows. The cell was constraining its contentView to zero width.
The workaround I used was to just add the contentView to the view hierarchy instead of the tableview cell. I also made sure to retain the tableView cell (as it was no longer being retained by the view hierarchy itself).
- Can OpenSSL be bundled for wget wrapper app to reference in Xcode project?
- Decrement index in a loop after Swift C-style loops deprecated
- Is there a way for XCode to warn about new API calls?
- How can i zoom in and out in a UIImageView without UIScrollView?
- EXC_BAD_ACCESS on NSManagedObjectContext save method inside NSOperation and ARC, why?
- Schedule multiple, daily events with NSTimer?
- Set view controllers of UITabBarController in Swift
- How do I store a Swift Struct in Core Data on iOS?
- Image resized error: CGBitmapContextCreate: unsupported parameter
- Testflight SDK and iOS Simulator – how to use?
- how to use DES algorithm to encrypt or decrypt some data in object-c？
- Story link flow using SSO facebook – openURL not being called
- Quickblox REST API Unexpected signature on Laravel
- Bluetooth Low Energy – updating a characteristic value repeatedly
- CoreBluetooth: How to design code for many characteristics (30 – 40)?