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>>)