简体   繁体   中英

Auto layout crash on iOS7, works great on iOS8

I am building an app with Xcode 6.1 (Beta) targeted for >iOS7. I have a prototype cell with all the constrains done in the storyboard. It works great on iOS8 (iPhone 6 simulator) and when I run on iOS7 (iPhone 5S simulator) it crashes with the following error:

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) 
(
"<NSLayoutConstraint:0x7f901848bf00 UILabel:0x7f90190cb410.trailing == UILabel:0x7f90190c8110.trailing>",
"<NSLayoutConstraint:0x7f901848bf50 H:[UILabel:0x7f90190cb410]-(19)-|   (Names: '|':UITableViewCellContentView:0x7f9019076440 )>",
"<NSLayoutConstraint:0x7f901848bfa0 UILabel:0x7f90190cb410.leading == UILabel:0x7f90190c8110.leading>",
"<NSLayoutConstraint:0x7f9018490900 H:|-(15)-[UILabel:0x7f90190cb410]   (Names: '|':UITableViewCellContentView:0x7f9019076440 )>",
"<NSAutoresizingMaskLayoutConstraint:0x7f90184a7800 h=--& v=--& H:[UITableViewCellContentView:0x7f9019076440(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7f901848bf00 UILabel:0x7f90190cb410.trailing == UILabel:0x7f90190c8110.trailing>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

This is my storyboard relevant stuff:

在此处输入图片说明

在此处输入图片说明

I have tried many different approaches for the constrains, they all crash every time I tell the label where it start (leading constrain) and where it ends (trailing...). And I don't want to give explicit height....

Any ideas?

You have two sets of constraints for the x position that might be conflicting. Try deleting either the pair of constraints that align the trailing and leading to the superview with an offset or the trailing and leading to subtitle-label.

your constraints might collide when your cell size is too small. In the interface builder resize the cell to be really small and see if it produces an error. If so you need to make sure you cell size is being set correctly

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM