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

时间:2014-10-14 08:11:33

标签: ios objective-c iphone uitableview ios7

我正在尝试将一个segue从tableview变成一个UIViewController,但是我收到了一个奇怪的错误。即使目标视图完全为空,也会发生错误,只是添加到故事板。我的想法是发送视图的一些元素是触发错误,但我很困惑,为什么这只是在退出TableViewController时显示,而不是在最初加载时。

这是错误的堆栈跟踪:

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)]>

2 个答案:

答案 0 :(得分:3)

我遇到了自定义UITableViewCell笔尖的同样问题。解除分配细胞的问题打破了限制。

尝试添加

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

答案 1 :(得分:0)

您正在为自己的观看视频添加约束,但您已在自己的translatesAutoresizingMaskIntoConstraints YES上设置contentView {{1}}。将其设置为NO - 您显然希望控制您的约束,而不是使用iOS的默认值。