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

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

i actually dont see my error:

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


        
9条回答
  •  时光说笑
    2021-01-03 19:56

    You are creating a FriendTableViewCell and then ignoring it and setting it equal to (presumably) an instance variable named friendCell.

    I assume that you expect friendCell to be set when calling the loadNibNamed method. It apparently is not being set.

    So you've got two problems with this code. First, don't allocate a cell twice.

    cell = [[[FriendTableViewCell ....
    [[NSBundle mainBundle .....
    cell = friendCell;
    

    Obviously, the creation of a new cell and assigning it to cell is useless if you are overwriting it with the second call to assignment to cell.

    Second, friendCell is probably nil. Make sure the NIB is set up correctly and has the outlets pointing to the right places.

提交回复
热议问题