为不可见单元格调用CellForRowAtIndexPath

时间:2015-07-29 07:10:42

标签: ios objective-c uitableview uiviewcontroller

我有一个高度为450的UITableView,我正在从笔尖加载一个高度为480的UITableView自定义单元格。根据我的理解CellForRowAtIndexPath只应该为可见细胞调用,但在我的情况下它被调用两次。我错过了什么吗?请帮忙。在这里编码

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ...

    cell.delegate = self;

    cell.playVideoButton.tag = indexPath.row;

    cell.commentLabel.text = videoPost.post_description;

    cell.videoUrl = videoPost.video;

    QBImageCache *coverImageCache = [[QBImageCache alloc]initWithUrl:coverImageUrl];

    UIImage *coverCache = [coverImageCache fetchImageFromCache];

    if (coverCache != nil) 
    {
        cell.coverImageView.image = coverCache;
    }
    else
    {
        cell.coverImageView.image = [UIImage imageNamed:@"contestDetailPlaceholder.jpg"];
        coverImageCache.cacheDelegate = self;
        coverImageCache.cacheDuration = 5;
        [coverImageCache fetchImage];
    }

      QBImageCache *profileImageCache = [[QBImageCache alloc]initWithUrl:profileImageUrl];

      UIImage *profileCache = [profileImageCache fetchImageFromCache];

     if (profileCache != nil) 
    {
        cell.profileImageView.image = profileCache;
    }
    else
    {
        cell.profileImageView.image = [UIImage imageNamed:@"user_avatar.png"];
        profileImageCache.cacheDelegate = self;
        profileImageCache.cacheDuration = 5;
        [profileImageCache fetchImage];
    }
        cell.avMoviePlayer.muted =NO;
        BOOL  visible = [self isIndexPathVisible:indexPath];

    if (visible ) 
    {
        NSLog(@"index inside play video   %ld",(long)indexPath.row);
        [self playVideoIncell:cell];
    }

  return cell;
}

0 个答案:

没有答案