【发布时间】:2016-03-15 20:45:52
【问题描述】:
我将图像添加到我的 tableView 单元格中,它使它变得迟钝。我对目标 c 还很陌生,我不明白是什么原因造成的或如何解决它。非常感谢任何帮助!
group[PF_GROUP_LOGO] 只是我数据库中每个对象唯一的字符串。代码有效,只是在尝试滚动时非常滞后。
//-------------------------------------------------------------------------------------------------------------------------------------------------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//-------------------------------------------------------------------------------------------------------------------------------------------------
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
PFObject *group = groups[indexPath.row];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:group[PF_GROUP_LOGO]]]];
cell.imageView.image = image;
cell.detailTextLabel.text = [NSString stringWithFormat:@"%d users", (int) [group[PF_GROUP_MEMBERS] count]];
cell.detailTextLabel.textColor = [UIColor lightGrayColor];
return cell;
}
【问题讨论】:
标签: ios objective-c uitableview