2014-01-15 38 views
0

我用一些UIImageViewsUILabels创建了自定义UiTableViewCell。 现在我有问题:当我滚动tableView我想在visiblePaths中获得cellForYoutube如何使用indexPath从UITableView访问自定义的UITableViewCell?

那我怎么想这样做:

- (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];} 

     } 
    } 
} 

如何解决这个问题?

+1

((UITableView的*)self.view)cellForRowAtIndexPath – santhu

+0

我有这个包括 –

回答

0

您正在发送-cellForRowAtIndexPath:消息到self.view这显然是UIView而不是UITableView。相反,发送消息给self.tableView(你叫-indexPathsForVisibleRows相同的对象。

铸造self.viewUITableView *告诉编译器相信该对象将是这种类型的,但不会是真的。

相关问题