2015-01-12 38 views
0

我正在使用集合視圖,我想根據滾動結束檢測來隱藏和取消隱藏圖像。但我無法隱藏圖像。另外,我想在我的tabbar上方顯示圖像。 另外,我怎樣才能把我的圖像總是在標籤欄之上,或者在收藏視圖中的任何單元格下方。無法隱藏集合視圖上的圖像IOS

我的代碼:

@interface 
UIImageView *arrow; 
end 

@implementation 
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; 
arrow = [[UIImageView alloc]initWithFrame:CGRectMake(20, 320, 20, 20)]; 
     arrow.image = [UIImage imageNamed:@"about"]; 
    [collectionView insertSubview:arrow belowSubview:cell ]; 
} 

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { 
    float bottomEdge = scrollView.contentOffset.y + scrollView.frame.size.height; 
    if (bottomEdge >= scrollView.contentSize.height) { 
     arrow.hidden=YES; 
    } 
} 
end 
+0

你期望從調用'arrow.hidden = YES;'得到什麼? –

+0

我想刪除該圖像。期待相同。 – developer

+0

哪張圖片,如果您向後滾動,您正在創造未知數量的圖片,每個細胞至少有一張圖片。 –

回答

0

確保你沒有創建一個以上的UIImageView。

您可以在1和2處放置斷點以檢查是否隱藏了相同的UIImageView對象。

1:arrow.image = [UIImage imageNamed:@「about」];

2:arrow.hidden = YES;