首页 > 其他 > 详细

Assertion failure in -[UITableViewCell layoutSublayersOfLayer:]

时间:2015-08-05 13:11:55      阅读:861      评论:0      收藏:0      [点我收藏+]

近日做ios的autolayout时候在兼容ios6的时候遇到以下Assert,但在ios7和ios8上就运行良好

Assertion failure in -[UITableViewCell layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2380.17/UIView.m:5776
required after executing -layoutSubviews. CategoryCell‘s implementation of -layoutSubviews needs to call super.

我的代码如下

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:UITableViewCellStyleValue1reuseIdentifier:@"default"];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        self.detailTextLabel.font = [UIFont systemFontOfSize:13];
        [self addBottomBorderWithHeight:0.5 color:APP_LINE_COLORleftOffset:15 rightOffset:15 andBottomOffset:0];  //assert发生在这一行,这行代码是在cell上添加一个autolayout的view
    }
    return self;
}


经过百度和google,网上给出的建议是禁用autolayout,我就郁闷了,难道因为吃饭会噎着就不吃饭了吗?

经过一下午的努力,终于解决了问题,将[self addBottomBorderWithHeight:...]改为[self.contentView addBottomBorderWithHeight:...],一切OK,跑的很顺畅

我想可能是在ios6上cell还不支持autolayout所导致的Assert。

大家有什么想法欢迎交流


Assertion failure in -[UITableViewCell layoutSublayersOfLayer:]

原文:http://aprogram.blog.51cto.com/10591497/1681789

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!