Kodeco Forums

Video Tutorial: Custom Collection View Layouts Part 7: Sticky Headers

Learn how to create a new type of layout, sticky headers, by following three rules.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3987-custom-collection-view-layout/lessons/8


Need to update the .NSDayCalendarUnit to NSCalendarUnit.Day


Iโ€™m following this tutorial in Xcode 10/ios 12. Everything appears to work as expected, but I see the following in the debug panel:

2019-05-15 10:49:04.417075+0100 Character Collector[76846:2735197] [LayoutConstraints] 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) 
    "<NSAutoresizingMaskLayoutConstraint:0x600001f4b610 h=--& v=--& UIView:0x7ff86b40fd50.width == 138   (active)>",
    "<NSLayoutConstraint:0x600001f4ad50 UIView:0x7ff86b40ff30.width == 200   (active)>",
    "<NSLayoutConstraint:0x600001f4b070 H:|-(0)-[UIView:0x7ff86b40ff30]   (active, names: '|':UIView:0x7ff86b40fd50 )>",
    "<NSLayoutConstraint:0x600001f4b110 H:[UIView:0x7ff86b40ff30]-(0)-|   (active, names: '|':UIView:0x7ff86b40fd50 )>"

I see this many times, presumably once per cell.

Any thoughts?

@skyrocketsw Can you please help with this when you get a chance? Thank you - much appreciated! :]

The hardcoded Autolayout width and height constraints of the cellโ€™s container view and UIImageView are in conflict with the values newly calculated by our layout subclass. The compiler responds by breaking one set of constraints, in our case luckily the correct one.
Try lowering the priority of all Autolayout width and height constraints with constants to 750. That will enable the compiler to ignore them in favour of the values that result from our layout calculations.

@danielmey Thank you for sharing the solution - much appreciated!