【发布时间】:2013-10-24 07:12:18
【问题描述】:
我正在开发的应用程序有问题。
我制作了一个带有自定义单元格的 UITableView。在单元格中,我使用 bezierPathWithRoundedRect: 方法放置了一个小 UIView 来显示用户的图像(从 Data Core 加载)
当我在应用程序中加载表格时,图像是正确的,直到我在表格上快速滚动。我认为图像的异步加载/编辑存在问题,但我不知道如何解决。如果我在单元格中使用简单的 UIImageView 而不是 UIView,则一切正常。 我在这里发现了非常相似的问题,但没有 UIView 类和数据核心加载...
这是我的单元格的代码:
- (UITableViewCell *)tableView:(UITableView *)presentTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"FellowshipCell";
UITableViewCell *cell = [presentTableView dequeueReusableCellWithIdentifier:cellIdentifier];
ExpenseParticipants *participant = [self.fetchedResultsController objectAtIndexPath:indexPath];
IconView *icon = (IconView *)[cell.contentView viewWithTag:1];
icon.immagine = [UIImage imageWithData:participant.usrImage];
return cell;
}
这是 UIView 类(IconView.h 和 IconView.m)的实现,用于绘制带有用户图像的圆形矩形:
- (void)drawRect:(CGRect)rect
{
// Draving code
UIBezierPath *icon = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:12];
[[UIColor greenColor] setFill];
UIRectFill(self.bounds);
[immagine drawInRect:self.bounds];
}
感谢您的帮助!
【问题讨论】:
标签: ios uitableview uiview