本文介绍了如何使图像在UITableViewCell滚动平滑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在加载图像到我的UITableViewCell,它变得浪潮。我只有大约5-10个单元格。
I'm loading images into my UITableViewCell and it is becoming choppy. I only have around 5-10 cells max.
有没有简单的方法来解决这个问题?
Are there any easy ways to fix this?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"appointmentCell";
AppointmentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSDictionary *appointmentDictionaryTemp = [self.appointmentArray objectAtIndex:indexPath.row];
cell.patientNameLabel.text = [appointmentDictionaryTemp objectForKey:@"patient"];
cell.appointmentTimeLabel.text = [appointmentDictionaryTemp objectForKey:@"scheduled_time"];
NSString *urlString = [[appointmentDictionaryTemp objectForKey:@"patient_small_photo_url"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSData * imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
UIImage * image = [UIImage imageWithData:imageData];
cell.patientImage.image = image;
return cell;
}
推荐答案
异步加载图片,他们。开始阅读此问题:
Load Images asynchronusly and maybe cache them. Start with reading this question: Lazy load images in UITableViewCell
这篇关于如何使图像在UITableViewCell滚动平滑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!