【发布时间】:2015-01-27 13:09:45
【问题描述】:
我需要一些帮助来了解可能导致我的 TableViewCell 内容出现问题的原因。在我的应用程序中,我使用论坛。在论坛中,我们使用 cmets/persons 的头像。现在我想给每个名字为“X”的人提供相同的头像。为此,我正在尝试使用下面的代码,但它不能完美运行,我不明白为什么?有时代码会出错,例如给别名为“Y”的人提供“X”别名头像?
1.我要做的第一件事是在storyboard中连接标签:tableView -> tableViewCell 将UIImageViews标签设置为20。
2。然后我运行下面的代码,该代码在其他情况下适用于 TableViewCells 内容中的别名、注释。
static NSString *CellIdentifier = @"ForumthreadCell";
UITableViewCell *cell = [pTableView dequeueReusableCellWithIdentifier:CellIdentifier];
ForumPost *x [self.items objectAtIndex:indexPath.row];
UIImageView *pic = (UIImageView *) [cell viewWithTag: 20];
if ([x.alias isEqualsToString:@"X"]){
[pic setImage:[UIImage imagedNamed:@"some picture here.png"]];
}
感谢任何帮助或建议。问候
【问题讨论】:
标签: ios uitableview uiimageview uiimage