简体   繁体   中英

UITableViewCell subclass not working

Any ideas why my cell won't show in the table. Its crashing at this code...

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"SetTableViewCell";
    SetTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil){        
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"SetTableViewCell" owner:nil options:nil];

        for(id currentObject in topLevelObjects)
        {
            if([currentObject isKindOfClass:[SetTableViewCell class]])
            {
                cell = (SetTableViewCell *)currentObject;
                break;
            }
        }
    }
    [self configureCell:cell atIndexPath:indexPath];

    return cell;
}

The most common thing in this case is forgetting to set the UITableViewCell object in interface builder to be of the class SetTableViewCell

Double check this from the Identity Inspector and make sure the Custom Class is set to SetTableViewCell

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM