簡體   English   中英

如何刪除不可見的tableview單元格的下載圖像。 在iOS中

[英]how to remove invisible tableview cell's downloaded image . in ios

滾動表格視圖時,我想在不可見的表格視圖單元格中刪除下載的圖像。

所以我設置了一個標簽

- (void)appImageDidLoad:(NSIndexPath *)indexPath
{
 int row=(int)indexPath
 UITableViewCell *cell;
 cell=[self.gamesTableView cellForRowAtIndexPath:indexPath];

 OneItemCell *cell1=(OneItemCell*) cell;   //custom cell

 cell1.imageview.tag= row+100;

 }

當選定的行是最后一行單元格(=添加單元格)時,我設置了刪除下載的圖像。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{  
     if(row==nArrayCount)
   {

  if(row>19) 
  {

    for(int i=1;i<row-8;i++)
    {


        [[self.gamesTableView viewWithTag:i+100] removeFromSuperview]; 

    }
 }

}

但它不起作用。 因為[[self.gamesTableView viewWithTag:i + 100]為NULL。

我通過NSMutableDictionary(= imageRemoveInProgress)為單元格的imageView設置密鑰的另一種方法

 - (void)appImageDidLoad:(NSIndexPath *)indexPath
   {                   .
                       .

        [imageRemoveInProgress setObject:cell1.imageView forKey:[NSNumber numberWithInt:row+100]];

   }



   - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {                     .
                       .
    [[imageRemoveInProgress objectForKey:[NSNumber numberWithInt:row+100]] removeFromSuperview];

 }

它也不起作用。 因為[[imageRemoveInProgress objectForKey:[NSNumber numberWithInt:row + 100]]也為NULL。

[[imageRemoveInProgress objectForKey:[NSNumber numberWithInt:row + 100]]在appImageDidLoad中具有值。

但是在-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath中

它具有NULL。

為什么標記和設置的鍵值單元格的imageView變為NULL?

如何刪除tableViewcell的imageview?

我不知道確切的方法,但是我可以提供一個提示

你可以用這樣的東西

NSArray * visiblePaths = [self.tableView indexPathsForVisibleRows];

visiblePaths是當前可見單元格的indexPaths數組,您可以檢查要刪除其圖像的單元格是否位於此數組中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM