I'm updating an existing app to autolayout to support more device sizes. I have a few objects which need to animate and instead of working with constrains I set them to:
self.secondCounter.translatesAutoresizingMaskIntoConstraints = YES //example
to use the old setFrame methods.
This seems to work but throws an runtime error on first animation:
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) ( "", "", "" )
Will attempt to recover by breaking constraint
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful. 2014-10-07 19:41:12.903 AppName[5018:1153922] 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) ( "", "", "" )
Will attempt to recover by breaking constraint
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.
In fact I don't get this message because I don't set any constrains on this object (I heard Xcode sets them per default on build for every view in an auto layout xib).
But somehow everything looks good and seems to work.
Can I just ignore this message or will I run into problems later?
You will definitely run into problems later and need to resolve this. If you don't satisfy all your constraints and the runtime correction system can't 'fudge the numbers', it can cause your app to crash. You can get nasty messages like this one:
Fatal Exception: NSInvalidArgumentException. Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil
In order to solve autolayout issues, follow some simple steps:
That's it! Find, fix, test :)
IMHO, The exception is a red herring.
The constraints are implicitely managed by apple. At some point a few lines of code 'over there' can indirectly affect them and thus it's a pain to discover why your code is raising an exception 'over here'
In my case i discovered a [cell setHidden:YES] went ahead and replaced that code with [cell removeFromSuperview] and the problem went away.
.... One of the tenants of OO programing is to make the APIS safe and easy to use. Not easily bruised and confused.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.