How do you load custom UITableViewCells from Xib files?

前端 未结 23 1976
抹茶落季
抹茶落季 2020-11-22 11:11

The question is simple: How do you load custom UITableViewCell from Xib files? Doing so allows you to use Interface Builder to design your cells. The answer app

23条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 11:30

    Correct Solution is this

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        [self.tableView registerNib:[UINib nibWithNibName:@"CustomCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"CustomCell"];
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        UITableViewCell  *cell = [tableView dequeueReusableCellWithIdentifier:@"CustomCell"];
        return cell; 
        }
    

提交回复
热议问题