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:
时你都在设置 image
.仅在 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 减慢滚动表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:uitableViewcell 中的 UIImage 减慢滚动表


- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01