简体   繁体   English

iOS 8自定义自调整表格视图:无法同时满足约束

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

In UITableViewController , I am using custom UITableView cell. UITableViewController ,我正在使用自定义UITableView单元格。 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 . 此单元包含UIImage对细胞的左侧和两个控制UILabels (一个为产品名称和其他为产品描述,其可具有不同长度),以此的权利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. (我选择990)解决了该问题。

Below is the link where i get the solution: 以下是我获得解决方案的链接:

ios8 cell constraints break when adding disclosure indicator 添加披露指标时,ios8单元约束被破坏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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