【发布时间】: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