uitableViewcell 中的 UIImage 减慢滚动表

UIImage in uitableViewcell slowdowns scrolling table(uitableViewcell 中的 UIImage 减慢滚动表)
本文介绍了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 减慢滚动表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)