2014-01-15 36 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 *告訴編譯器相信該對象將是這種類型的,但不會是真的。

相關問題