iphone - UITableView dataSource 必须从 tableView :cellForRowAtIndexPath: Exception 返回一个单元格

标签 iphone uitableview

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

- (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;
}

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

感谢您的帮助!

最佳答案

你正在返回friendCell,它很可能为零。

您的代码看起来不错,因此请确保您的 Interface Builder 文件设置正确。在 FriendTableViewCell.xib 中,确保文件的所有者是您的 TableView Controller ,并且您正确地将单元格设置为friendCell(我假设是 UITableViewCell)的导出。

关于iphone - UITableView dataSource 必须从 tableView :cellForRowAtIndexPath: Exception 返回一个单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2224316/

相关文章:

iOS 表格 View 刷新单元格

iphone - 如何再次要求用户注册 RemoteNotifications?

objective-c - 遵守协议(protocol)有什么好处,如果父类(super class)这样做,我是否需要声明它?

ios - UISearchbar Controller 出现问题,显示结果?

iphone - 通过核心数据的不同计数,NSExpression 到 NSFetchedResultsController

ios - 高度从 0 变为默认大小后单元格不显示

ios - viewWillAppear 期间的静态 UITableViewCell 更改未反射(reflect)在显示中

ios - 如果我只是在其中添加 ScrollView ,NSLayoutConstraint 会给出很多警告

iphone - 在 iOS 上是否可以自定义推送通知

适用于德国应用商店的 iPhone 应用(本地化)