UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath: Exception

后端 未结 9 2171
悲&欢浪女
悲&欢浪女 2021-01-03 19:15

i actually dont see my error:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  static NSString *Cel         


        
9条回答
  •  旧时难觅i
    2021-01-03 19:54

    I found that this problem came when trying to create my UITableViewCell before initialising my table view:

    Here registering the class before creating the tableView will cause the error, placing it after will fix the error.

    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:bCellIdentifier]; 
    
    tableView = [[UITableView alloc] initWithFrame:CGRectZero];
    tableView.delegate = self;
    tableView.dataSource = self;
    
    [self addSubview:tableView];
    
    tableView.keepInsets.equal = KeepRequired(0);
    

提交回复
热议问题