HorizonCalendar icon indicating copy to clipboard operation
HorizonCalendar copied to clipboard

Breaking constraints

Open StewieGilliganGriffin opened this issue 3 years ago • 3 comments

Hello! I have an issue with creating my own custom dayView, it's called "CalendarDayView". It seems that some of constraints inside of your calendar view became broken after adding my CalendarDayView. Please help!

`Will attempt to recover by breaking constraint <NSLayoutConstraint:0x600000f065d0 H:[UIView:0x151d79770]-(1)-| (active, names: '|':ReportingSystem.CalendarDayView:0x151d795f0 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful. 2021-10-25 16:43:05.072944+0300 ReportingSystem[6276:181178] [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:0x600000f783c0 h=--& v=--& ReportingSystem.CalendarDayView:0x151d33a70.height == 0 (active)>", "<NSLayoutConstraint:0x600000f03610 V:|-(2)-[UIView:0x151d2abc0] (active, names: '|':ReportingSystem.CalendarDayView:0x151d33a70 )>", "<NSLayoutConstraint:0x600000f036b0 V:[UIView:0x151d2abc0]-(2)-| (active, names: '|':ReportingSystem.CalendarDayView:0x151d33a70 )>" )`

Снимок экрана 2021-10-25 в 16 43 41

StewieGilliganGriffin avatar Oct 25 '21 13:10 StewieGilliganGriffin

Hey @StewieGilliganGriffin - the likely issue is that your CalendarDayView has subviews that are pinned to the top/bottom/leading/trailing edges or margins. Day views are not sizes based on the intrinsic size of its subviews, but rather, sized based on the metrics you pass in to CalendarViewContent + the width of the CalendarView. For example, if you have a CalendarView that's 345pt wide, and you set the horizontalDayMargin to 5, then that leaves 315pt left for each of your CalendarDayViews. If you divider 315 / 7, that will mean each day view is 45pt wide and 45pt tall.

You'll need to make sure that your CalendarDayView can be 45x45 without its constraints breaking (in the example that I gave). You can do this by using non-required constraint priorities, for example.

If you need more help, feel free to share your CalendarDayView code and I can help figure out what changes are needed 🙂

bryankeller avatar Nov 03 '21 02:11 bryankeller

Hi @bryankeller, I got the issue with HorizonCalendar.DoubleLayoutPassSizingLabel, I just following the document for creating the CalendarViewContent

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. 
(
    "<NSLayoutConstraint:0x6000016ac000 HorizonCalendar.DoubleLayoutPassSizingLabel:0x141924210.leading == UILayoutGuide:0x600000c8dea0'UIViewLayoutMarginsGuide'.leading   (active)>",
    "<NSLayoutConstraint:0x6000016acc30 HorizonCalendar.DoubleLayoutPassSizingLabel:0x141924210.trailing == UILayoutGuide:0x600000c8dea0'UIViewLayoutMarginsGuide'.trailing   (active)>",
    "<NSLayoutConstraint:0x6000016ac870 '_UITemporaryLayoutWidth' HorizonCalendar.CalendarView:0x143880c00.width == 0   (active)>",
    "<NSLayoutConstraint:0x6000016ac280 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x600000c8dea0'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':HorizonCalendar.CalendarView:0x143880c00 )>",
    "<NSLayoutConstraint:0x6000016ac140 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600000c8dea0'UIViewLayoutMarginsGuide']-(8)-|(LTR)   (active, names: '|':HorizonCalendar.CalendarView:0x143880c00 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x6000016acc30 HorizonCalendar.DoubleLayoutPassSizingLabel:0x141924210.trailing == UILayoutGuide:0x600000c8dea0'UIViewLayoutMarginsGuide'.trailing   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2023-04-19 23:34:31.168185+0700 NorepaApp[20624:406080] [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. 
(
    "<NSLayoutConstraint:0x6000016acaa0 HorizonCalendar.DoubleLayoutPassSizingLabel:0x141924210.top == UILayoutGuide:0x600000c8dea0'UIViewLayoutMarginsGuide'.top   (active)>",
    "<NSLayoutConstraint:0x6000016aca00 HorizonCalendar.DoubleLayoutPassSizingLabel:0x141924210.bottom == UILayoutGuide:0x600000c8dea0'UIViewLayoutMarginsGuide'.bottom   (active)>",
    "<NSLayoutConstraint:0x6000016a8320 '_UITemporaryLayoutHeight' HorizonCalendar.CalendarView:0x143880c00.height == 0   (active)>",
    "<NSLayoutConstraint:0x6000016ac1e0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x600000c8dea0'UIViewLayoutMarginsGuide']-(8)-|   (active, names: '|':HorizonCalendar.CalendarView:0x143880c00 )>",
    "<NSLayoutConstraint:0x6000016ac320 'UIView-topMargin-guide-constraint' V:|-(8)-[UILayoutGuide:0x600000c8dea0'UIViewLayoutMarginsGuide']   (active, names: '|':HorizonCalendar.CalendarView:0x143880c00 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x6000016aca00 HorizonCalendar.DoubleLayoutPassSizingLabel:0x141924210.bottom == UILayoutGuide:0x600000c8dea0'UIViewLayoutMarginsGuide'.bottom   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2023-04-19 23:34:31.174473+0700 NorepaApp[20624:406080] [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. 
(
    "<NSLayoutConstraint:0x6000016ae8f0 HorizonCalendar.DoubleLayoutPassSizingLabel:0x14195bf10.leading == UILayoutGuide:0x600000c8e220'UIViewLayoutMarginsGuide'.leading   (active)>",
    "<NSLayoutConstraint:0x6000016aead0 HorizonCalendar.DoubleLayoutPassSizingLabel:0x14195bf10.trailing == UILayoutGuide:0x600000c8e220'UIViewLayoutMarginsGuide'.trailing   (active)>",
    "<NSLayoutConstraint:0x6000016ae490 '_UITemporaryLayoutWidth' HorizonCalendar.CalendarView:0x1428cec00.width == 0   (active)>",
    "<NSLayoutConstraint:0x6000016ae990 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x600000c8e220'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':HorizonCalendar.CalendarView:0x1428cec00 )>",
    "<NSLayoutConstraint:0x6000016ae710 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600000c8e220'UIViewLayoutMarginsGuide']-(8)-|(LTR)   (active, names: '|':HorizonCalendar.CalendarView:0x1428cec00 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x6000016aead0 HorizonCalendar.DoubleLayoutPassSizingLabel:0x14195bf10.trailing == UILayoutGuide:0x600000c8e220'UIViewLayoutMarginsGuide'.trailing   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2023-04-19 23:34:31.189981+0700 NorepaApp[20624:406080] [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. 
(
    "<NSLayoutConstraint:0x6000016ae8a0 HorizonCalendar.DoubleLayoutPassSizingLabel:0x14195bf10.top == UILayoutGuide:0x600000c8e220'UIViewLayoutMarginsGuide'.top   (active)>",
    "<NSLayoutConstraint:0x6000016ae940 HorizonCalendar.DoubleLayoutPassSizingLabel:0x14195bf10.bottom == UILayoutGuide:0x600000c8e220'UIViewLayoutMarginsGuide'.bottom   (active)>",
    "<NSLayoutConstraint:0x6000016916d0 '_UITemporaryLayoutHeight' HorizonCalendar.CalendarView:0x1428cec00.height == 0   (active)>",
    "<NSLayoutConstraint:0x6000016aec10 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x600000c8e220'UIViewLayoutMarginsGuide']-(8)-|   (active, names: '|':HorizonCalendar.CalendarView:0x1428cec00 )>",
    "<NSLayoutConstraint:0x6000016aeb20 'UIView-topMargin-guide-constraint' V:|-(8)-[UILayoutGuide:0x600000c8e220'UIViewLayoutMarginsGuide']   (active, names: '|':HorizonCalendar.CalendarView:0x1428cec00 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x6000016ae940 HorizonCalendar.DoubleLayoutPassSizingLabel:0x14195bf10.bottom == UILayoutGuide:0x600000c8e220'UIViewLayoutMarginsGuide'.bottom   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

longhoang2984 avatar Apr 19 '23 16:04 longhoang2984

I fixed by re-calculate frame, thanks

longhoang2984 avatar Apr 19 '23 17:04 longhoang2984