UITableViewCell的-layoutSubviews实现需要调用super

时间:2014-10-31 04:14:32

标签: ios objective-c iphone masonry-ios-osx

我在UITableViewCell中添加一个视图,并使用mas_makeConstraints(Masonry)

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kMASCellReuseIdentifier forIndexPath:indexPath];

UIView * view =[[UIView alloc]init];

view.backgroundColor=[UIColor redColor];

[cell addSubview:view];

[view mas_makeConstraints:^(MASConstraintMaker *make){
    make.right.equalTo(cell).offset(-20);
    make.centerY.equalTo(cell);
    make.width.height.equalTo(@20);
}];

但它不起作用。

错误讯息: 由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'执行-layoutSubviews后仍需要自动布局。 UITableViewCell的-layoutSubviews实现需要调用super。'

请帮帮我! @。@

1 个答案:

答案 0 :(得分:0)

更好的是,为什么不通过IB制作自定义UITableViewCell并添加您需要的视图。