2013-11-23 28 views
1

我有一個UITableView持有的FBProfilePictureViewUILableFBProfilePictureView在一個UITableView重新創建它自己每次

我的問題是,當用戶滾動畫面重建自身,需要時間來顯示圖像它的自我,我想知道如何創建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; 

    } 



} 

任何幫助將是巨大的傢伙...

非常感謝。

回答

相關問題