简体   繁体   中英

iOS 8 Custom Self Sizing Table View : Unable to simultaneously satisfy constraints

In UITableViewController , I am using custom UITableView cell. This cell contains a UIImage control on left side of cell and two UILabels (one is for product name and other is for product description, which can be varying length) to the right of this UIImage . I have added Auto Layout constraints on all three controls. There is no issue in Auto Layout control. However when I run the app, I get the following error messages (one for each row in the table) and a couple of top rows are not as per auto layout constraints, but however when I scroll down and then scroll up, everything is rendered as per the auto layout constraints

Debug Log:
-----------------------------------------------------------------------------
- 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:0x170085ff0 H:[PFImageView:0x14ee1d350(60)]>",
    "<NSLayoutConstraint:0x17408a500 PFImageView:0x14ee1d350.leading == UITableViewCellContentView:0x14ee1cdf0.leadingMargin + 7>",
    "<NSLayoutConstraint:0x17408a5a0 UITableViewCellContentView:0x14ee1cdf0.trailingMargin == UILabel:0x14ed08580'Naturally Sandstone Slabs'.trailing + 10>",
    "<NSLayoutConstraint:0x17408a5f0 H:[PFImageView:0x14ee1d350]-(11)-[UILabel:0x14ed08580'Naturally Sandstone Slabs']>",
    "<NSLayoutConstraint:0x17008c6c0 'fittingSizeHTarget' H:[UITableViewCellContentView:0x14ee1cdf0(34)]>" )

Will attempt to recover by breaking constraint  <NSLayoutConstraint:0x170085ff0 H:[PFImageView:0x14ee1d350(60)]>

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.

The issue was because i was using a disclosure indicator in the table view. Lowering the priority of label's trailing-to-superview constraint. (I chose 990) fixed the issue.

Below is the link where i get the solution:

ios8 cell constraints break when adding disclosure indicator

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