2015-01-12 30 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;