【发布时间】:2013-02-02 08:30:32
【问题描述】:
我关注了Connect outlet of a Cell Prototype in a storyboard
所以我的插座已连接。我有这个方法:
- (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?是否调用了数据源方法?
-
在调试器中检查单元格是正确的类并且单元格项不为零。
NSLog(@"cell class: %@", NSStringFromClass([cell class])); -
@Zaph 它显示 homecell,故事板中的类也显示 HomeCell...
-
但是当我这样做时 [[cell textLabel] setText:@"hi"];它显示你好
-
但是当我点击它时它会显示 HomeCell...看起来有某种重叠发生
标签: ios uitableview uistoryboard