uitableViewcell中的UIImage减慢滚动表 [英] UIImage in uitableViewcell slowdowns scrolling table
本文介绍了uitableViewcell中的UIImage减慢滚动表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我想在Table的cell.image中获取facebook用户的个人资料图片。但它减慢了表视图的滚动速度。然后我使用了异步加载图像链接但我很困惑,我怎么能在我的表的方法中使用它
Hello I am trying to get profile image of facebook user in Table's cell.image. But It slows down Scrolling of Table view.Then I used Asynchronous loading of image link But i am confused how could I use this in my Table's method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.font = [ UIFont fontWithName:@"Arial" size:10.0];
cell.textLabel.numberOfLines = 0;
cell.textLabel.text = [NSString stringWithFormat:@"%@",[(Facebook *)[dummyArray objectAtIndex:indexPath.row] sender]];
cell.detailTextLabel.text =[NSString stringWithFormat:@"%@",[(Facebook *)[dummyArray objectAtIndex:indexPath.row] post]];
NSString *get_string = [NSString stringWithFormat:@"%@/picture",[(Facebook *)[dummyArray objectAtIndex:indexPath.row]senderId]];
AsynchronousImageView *image = [[AsynchronousImageview alloc]init];
[image loadImagewithUrlString:getString];
FbGraphResponse *fb_graph_response = [fbGraph doGraphGet:get_string withGetVars:nil];
UIImageView *image_view = [[UIImageView alloc] initWithImage:fb_graph_response.imageResponse];
cell.imageView.image = image_view.image;
[image_view release];
return cell;
}
推荐答案
因为你的速度减慢了每次调用 cellForRowAtIndexPath:
时设置图像
。仅在 if(cell == nil)
块内添加图像到单元格的imageView。然后你会看到滚动的改进。
Its slows down because you are setting the image
every time the cellForRowAtIndexPath:
is called. Add the image to the cell's imageView only inside the if (cell == nil)
block. Then you will see the improvement in scrolling.
这篇关于uitableViewcell中的UIImage减慢滚动表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文