0

I add a view in UITableViewCell , and use 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);
}];

but it not work.

error message: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UITableViewCell's implementation of -layoutSubviews needs to call super.'

please help me ! @.@

4

1 に答える 1

0

さらに良いことに、カスタムUITableViewCellを作成して必要なビューを IB 経由で追加するだけではどうですか。

于 2014-10-31T06:03:14.877 に答える