Custom UITableViewCell Not Using .xib (Most Likely Because of Flaw in init Method)

后端 未结 3 1569
温柔的废话
温柔的废话 2020-12-10 09:36

I subclassed the UITableViewCell in order to customize it, but I think I\'m missing something because: 1) It\'s not working and 2) There are a couple of things I\'m confused

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 10:07

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *simpleTableIdentifier = @"CueTableCell";
    
        CueTableCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
    
        if (cell == nil) {
            NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"CueTableCell XibName" owner:self options:nil];
            // Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
            cell = [array objectAtIndex:0];
        }
    
        return cell;
    }
    

提交回复
热议问题