UITableView dataSource必须从tableView返回一个单元格:cellForRowAtIndexPath:Exception [英] UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath: Exception

查看:141
本文介绍了UITableView dataSource必须从tableView返回一个单元格:cellForRowAtIndexPath:Exception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上没有看到我的错误:

i actually dont see my error:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  static NSString *CellIdentifier = @"Cell";

  FriendTableViewCell *cell = (FriendTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
      cell = [[[FriendTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
      [[NSBundle mainBundle] loadNibNamed:@"FriendTableViewCell" owner:self options:nil];
      cell = friendCell;
  }
  cell.lblNickname.text =  @"Tester";
  return cell;
}

我做错了什么?我检查了两次..但没有看到错误。

What am i doing wrong? I checked all twice.. but dont see the error.

感谢您的帮助!

推荐答案

你回来了朋友凯尔,而且很可能是零。

You're returning friendCell, and it's very likely nil.

您的代码看起来很好,因此请确保您正确设置了Interface Builder文件。在FriendTableViewCell.xib中,确保文件所有者是您的表视图控制器,并且您正确地将单元格设置为friendCell的出口(我假设是UITableViewCell)。

Your code looks fine, so make sure you have your Interface Builder file set up right. In FriendTableViewCell.xib, be sure the File's Owner is your table view controller and that you correctly set the cell to be an outlet to friendCell (which I assume is a UITableViewCell).

这篇关于UITableView dataSource必须从tableView返回一个单元格:cellForRowAtIndexPath:Exception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆