我使用UiTableViewCell
和UIImageViews
创建了自定义UILabels
。
现在我遇到了问题:当我滚动tableView
时,我希望在visiblePaths中获得此cellForYoutube
。
这就是我尝试这样做的方法:
- (void)loadImagesForOnscreenRows
{
if (videos.count > 0)
{
NSArray *visiblePaths = [self.tableView indexPathsForVisibleRows];
for (NSIndexPath *indexPath in visiblePaths)
{cellForYoutube *cell = (cellForYoutube *)[(UITableView *)self.view cellForRowAtIndexPath:indexPath];
//There it show me erorr: -[UIView cellForRowAtIndexPath:]: unrecognized selector sent to instance.
if (!cell.thumb.image){
NSLog(@"WAS NOTHING IN IMAGE");
[self startIconDownload:cell withIndexPath:indexPath];}
}
}
}
如何解决?
答案 0 :(得分:0)
您正在向-cellForRowAtIndexPath:
发送self.view
消息,该消息显然是UIView
而不是UITableView
。而是将该消息发送到self.tableView
(您调用-indexPathsForVisibleRows
的同一对象。
将self.view
强制转换为UITableView *
会告诉编译器相信该对象属于该类型但不会这样做。