Closed k3zi closed 8 years ago
Hi, what is content of the warning message and when will the debug console output it?
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:0x14f664a00 h=--& v=--& H:[KMPlaceholderTextView.KMPlaceholderTextView:0x150069c00(0)]>",
"<NSLayoutConstraint:0x14f780e40 UILabel:0x14f664340'Stream Description...'.width == KMPlaceholderTextView.KMPlaceholderTextView:0x150069c00.width - 40>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x14f780e40 UILabel:0x14f664340'Stream Description...'.width == KMPlaceholderTextView.KMPlaceholderTextView:0x150069c00.width - 40>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
Once I lower the priority of the constraint it breaks then it stops showing these warnings. The label "Stream Description..." in the logs is the text from the placeholder. This warning is output when the view and its subviews layout on the screen.
I suggest you to use auto layout instead of autoresizing mask to position KMPlaceholderTextView, you could set the translatesAutoresizingMaskIntoConstraints
property of KMPlaceholderTextView to NO
when using auto layout.
I'm already using PureLayout which sets that property to false by default.
Why the KMPlaceholderTextView still has NSAutoresizingMaskLayoutConstraint
?
It seems I was setting up my constraints to late so the display loaded the view with translatesAutoresizingMaskIntoConstraints set to true.
It still seems that the view is being over constrained though. You set the leading and trailing distance in accordance with the inset but then you also set the width equal to the container. You would only have to to set either:
Setting all three would be unnecessary.
Adding the width constraint is to fix this issue https://github.com/MoZhouqi/KMPlaceholderTextView/issues/9.
Oh, I see... The way to go then would be to disable one of the leading/trailing constraints, right?
Why don't you consider to set the translatesAutoresizingMaskIntoConstraints
property to false
?
Fixed in d670bb34adb98f6f4e328c5e29ed8eafd84838f6. Thanks for the awesome details!
If the priority of the width constraint isn't reduced it is automatically broken. Running this without the priority lowered generates a string of warnings in the console log, meaning that this is being over constrained.