Search code examples
iosobjective-ciphonemasonry-ios-osx

UITableViewCell's implementation of -layoutSubviews needs to call super


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 ! @.@


Solution

  • Better yet, why not just make a custom UITableViewCell and add the views you need to it, via IB.