【问题标题】:Unable to hide image on collection view IOS无法在集合视图 IOS 上隐藏图像
【发布时间】:2015-03-10 10:20:56
【问题描述】:

我正在使用集合视图,我想根据滚动结束检测隐藏和取消隐藏图像。但我无法隐藏图像。另外,我想在我的标签栏上方显示图像。 另外,我怎样才能将我的图像始终放在标签栏上方,或者放在集合视图中的任何单元格下方。

我的代码:

@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

【问题讨论】:

  • 您希望通过致电arrow.hidden=YES; 得到什么?
  • 我想删除该图像。期待同样的结果。
  • 哪个图像,您正在创建未知数量的图像,每个单元格至少一个,如果您向后滚动,则会更多。
  • 我只是在标签栏控制器上方创建一个图像。向下滚动时隐藏也是如此
  • 该图像只是一个指示。

标签: ios objective-c image uicollectionview


【解决方案1】:

确保您没有创建多个 UIImageView。

您可以在 1 和 2 处放置断点,以检查您是否隐藏了相同的 UIImageView 对象。

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

2:箭头.hidden=YES;

【讨论】:

    猜你喜欢
    • 2017-06-15
    • 2020-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多