简体   繁体   English

iOS:在segue中无法同时满足约束

[英]iOS: Unable to simultaneously satisfy constraints when in segue

I am trying to make a segue from a tableview into a UIViewController, but I'm getting a curious error. 我试图从一个tableview到一个UIViewController做一个segue,但我得到一个奇怪的错误。 The error occurs even if the target view is completely empty, just added to the storyboard. 即使目标视图完全为空,也会发生错误,只是添加到故事板。 My thought is some element of sending view is triggering the error, but I am confused why this is only showing when exiting that TableViewController, not when loading it initially. 我的想法是发送视图的一些元素是触发错误,但我很困惑,为什么这只是在退出TableViewController时显示,而不是在最初加载时。

This is the stack trace form the error: 这是堆栈跟踪形式的错误:

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.
2014-10-14 00:52:23.472 Phood[54950:70b] 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:0x9d56270 H:[PHStarsView:0x9d9c4a0(70)]>",
    "<NSLayoutConstraint:0xf544940 H:|-(20)-[PHStarsView:0x9d9c4a0]   (Names: '|':UITableViewCellContentView:0x9fcd710 )>",
    "<NSLayoutConstraint:0xf543d90 H:[PHStarsView:0x9d9c4a0]-(80)-|   (Names: '|':UITableViewCellContentView:0x9fcd710 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x9d774e0 h=--& v=--& H:[UITableViewCellContentView:0x9fcd710(320)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x9d56270 H:[PHStarsView:0x9d9c4a0(70)]>

I ran into the same problem with a custom UITableViewCell nib. 我使用自定义UITableViewCell笔尖遇到了同样的问题。 Something about deallocating the cell breaks constraints. 关于解除分配细胞的问题打破了限制。

Try adding 尝试添加

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewAutomaticDimension;
}

You are adding constraints to your views and yet you have translatesAutoresizingMaskIntoConstraints set to YES on your cell's contentView . 您正在为视图添加约束,但您已在单元格的contentView上将translatesAutoresizingMaskIntoConstraints设置为YES Set that to NO--you obviously want to be in control of your constraints and not use iOS's defaults. 将其设置为NO - 您显然希望控制您的约束而不使用iOS的默认值。

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

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