我有一个高度为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;
}