我实际上没有看到我的错误:
- (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/