我跟着Connect outlet of a Cell Prototype in a storyboard表格单元不连接到iOS故事板的插座
所以我的插座已连接。我有这种方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
HomeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[HomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] ;
}
// Configure the cell.
Group * group = [self.groups objectAtIndex: [indexPath section]];
Friend * friend = [[group friends ]objectAtIndex: [indexPath row]];
NSLog(@"%@", friend.name);
[[cell nameLabel] setText:friend.name];
[[cell statusLabel] setText:friend.status];
[[cell picImageView] setImage:[UIImage imageNamed:@"similey.jpg"]];
return cell;
}
它编译得很好,但单元格显示空白,没有任何内容。有什么建议么?
您是否将故事版中的单元格类更改为HomeCell?数据源方法是否被调用? – rdelmar 2013-02-17 23:44:30
检查调试器中的单元格是否正确,并且单元格项不为零。 'NSLog(@“cell class:%@”,NSStringFromClass([cell class]));' – zaph 2013-02-18 00:02:48
@Zaph它显示homecell 和故事板中的类显示HomeCell以及... – SuperString 2013-02-18 00:30:51