Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:]

本文介绍了一种在UITableView中遇到的断言失败问题的具体解决方案,通过注册单元格的方式避免了Assertion failure in -[UITableView configureCellForDisplay:forIndexPath:]错误的发生。
今天在写创建一个UItableviewcontroller的时候遇到了Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:]的断言报错信息,试了各种方法都没解决问题之后,终于在论坛上找到了解决方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString * cellId=@"BaseCell";
    static BOOL nibsRegistered = NO;
    if(!nibsRegistered)
    {
        UINib *nib = [UINib nibWithNibName:@"BaseCellTableViewCell" bundle:nil];
        [tableView registerNib:nib forCellReuseIdentifier:cellId];
        nibsRegistered = YES;
    }
    BaseCellTableViewCell * cell=(BaseCellTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:cellId];
    cell.NameLabel.text=@"xxx商城";
    cell.PhoneLabel.text=@"12345678";
    cell.PhoneLabel.font=[UIFont systemFontOfSize:12];
    cell.CellImageView.image=[UIImage imageNamed:@"test1.png"];
    [cell setLocationLabel:cell.LocationLabel];
    [cell setIcon2Image:cell.icon2Image];
    [cell setIcon1Image:cell.icon1Image];
    cell.selected=YES;
    
    return cell;
}



原因暂时只知道是注册cell的问题,还没有找到具体的答案,以后自定义的cell尽量中这种方式生成
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值