ios - uitableview 中的 FBProfilePictureView 每次都会自行重新创建

标签 ios objective-c uitableview facebook-ios-sdk

我有一个 UITableView,它包含一个 FBProfilePictureView 和一个 UILable

我的问题是,当用户滚动图片时,图片会自行重建,并且需要时间来显示图片本身,我想知道如何在用户滚动时创建一次 FBProfilePictureView它不会再自行构建。

这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    Messages *msg = [messages objectAtIndex:indexPath.row];
    NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
    NSData *encodedDataObject = [def objectForKey:@"myUser"];
    User *user = (User *)[NSKeyedUnarchiver unarchiveObjectWithData: encodedDataObject];

    if(![msg.wrote_id isEqualToString:user.fid])
    {
        NSString *idToImage = [self getOtherUserId];
        NSString *CellIdentifier = @"Cell";
        ChatWindowCell *cell = nil;
        cell = (ChatWindowCell *)[tableChat dequeueReusableCellWithIdentifier:CellIdentifier];

        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ChatWindowCell" owner:nil options:nil];
        for(id currentObject in topLevelObjects)
        {
            if([currentObject isKindOfClass:[ChatWindowCell class]])
            {
                cell = (ChatWindowCell *) currentObject;
                cell.profile_image.profileID=nil;
                if(cell.profile_image.profileID.length>0)
                {

                    return cell;
                }
                break;
            }
        }
        cell.profile_image.profileID = idToImage;
        NSString *text = msg.msg;
        cell.lblMessage.text=text;
        return cell;
    }
    else
    {
        NSString *CellIdentifier = @"Cell";
        ChatCellMe *cell = nil;
        cell = (ChatCellMe *)[tableChat dequeueReusableCellWithIdentifier:CellIdentifier];
        //  if (cell == nil) {

        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ChatCellMe" owner:nil options:nil];
        for(id currentObject in topLevelObjects)
        {
            if([currentObject isKindOfClass:[ChatCellMe class]])
            {
                cell = (ChatCellMe *) currentObject;
                NSLog(cell.prof_img.profileID);
                cell.prof_img.profileID=nil;

                if(cell.prof_img.profileID.length>0)
                {
                    return cell;
                }
                break;
            }
        }

        cell.prof_img.profileID = user.fid;
        NSString *text = msg.msg;
        cell.lblText.text=text;
        isMessageFromMe=false;
        return cell;

    }



}

任何帮助都会很棒...

非常感谢。

最佳答案

我创建了一个替代 View 来解决这个问题,请参阅 https://github.com/combinatorial/DBFBProfilePictureView

关于ios - uitableview 中的 FBProfilePictureView 每次都会自行重新创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20160758/

相关文章:

ios - UIButton addTarget 参数在 UIViewCollectionView 里面

iOS Xcode : UIButton titleLabel color keeps changing

ios - heightForRowAtIndexPath 无法正常工作

iphone - 重写子类中的观察者方法

ios - 按字母顺序将数组拆分为多个数组iOS

iOS 模拟器第一次启动需要很长时间

ios - Afnetworking 2 基本授权帖子

iphone - 用户在app purchase中重新购买时,paymentQueue::updatedTransactions应该被iOS调用?

swift - 点击 tableview 单元格时如何更改 UIImage 颜色?

ios - 多个 UITableViewCell 类型以编程方式