美文网首页
UITableViewCell加载时的错误

UITableViewCell加载时的错误

作者: tanlon | 来源:发表于2016-08-18 22:32 被阅读575次

    static NSString *identifier = @"TypeTableViewCellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    !!!!!!!! 注意cell的判断
    if (cell) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    cell.backgroundColor = [UIColor whiteColor];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.textLabel.text = [_arrTypes objectAtIndex:indexPath.row];

    return cell;
    

    }

    注释:如果cell的判断写成上面那样,会报出下面的错误:
    reason: UITableView (<UITableView: 0x15bd2200; frame = (0 0; 200 300); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x1609e4c0>; layer = <CALayer: 0x160a7510>; contentOffset: {0, 0}; contentSize: {200, 880}>) failed to obtain a cell from its dataSource (<TypeTableView: 0x1637bb30; frame = (0 0; 375 667); layer = <CALayer: 0x14fde740>>)

    相关文章

      网友评论

          本文标题:UITableViewCell加载时的错误

          本文链接:https://www.haomeiwen.com/subject/hrtbsttx.html