bsp; [downloader release]; |
} |
- (void)loadImagesForOnscreenRows |
{ |
#pragma mark indexPathsForVisibleRows-->没看到过 |
//获取tableview正在window上显示的cell,加载这些cell上图像。通过indexPath可以获取该行上需要展示的cell对象 |
NSArray * visibleCells = [self.tableView indexPathsForVisibleRows]; |
for (NSIndexPath * indexPath in visibleCells) { |
NewsItem * item = [_dataArray objectAtIndex:indexPath.row]; |
if (item.newsPic == nil) { |
//如果新闻还没有下载图像,开始下载 |
[self startPicDownload:item forIndexPath:indexPath]; |
} |
} |
} |
#pragma mark - 延迟加载关键 |
//tableView停止拖拽,停止滚动 |
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate |
{ |
//如果tableview停止滚动,开始加载图像 |
if (!decelerate) { |
[self loadImagesForOnscreenRows]; |
} |
NSLog(@"%s__%d__|%d",__FUNCTION__,__LINE__,decelerate); |
} |
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView |
{ |
//如果tableview停止滚动,开始加载图像 |
[self loadImagesForOnscreenRows]; |
} |