问题描述
这是一个经常发生的错误,但并非总是如此.我有一个刷新控件添加到我的 UICollectionView.当我刷新时,它完美地工作.但是,如果我多次刷新它甚至完全刷新,请转到应用程序中的另一个选项卡,然后返回,当我刷新时,UIRefreshControl 出现在 UICollectionView 的一部分上.此外,它不是从零刷新微调条开始,而是从所有加载开始(尽管我在其他应用程序中注意到了这一点,例如 Mail,所以这是一个操作系统错误,但在操作系统应用程序中,微调器不会过去内容).这是问题的图片:https://www.dropbox.com/s/4qk6qjrdlapsvz0/IMG_0074.JPG一>这是我在 ViewDidLoad 中设置 RefreshController 的方法.
This is a bug that happens frequently, but not always. I have a refresh control added to my UICollectionView. When I refresh, it works perfectly. However, if I half refresh it several times or even do a full refresh, go to another tab in the app, and then return back, when I refresh, the UIRefreshControl appears over part of the UICollectionView. Additionally, instead of starting from zero refresh spinner bars, it starts with all loaded (I've noticied this in other apps such as Mail though, so that much is an OS bug, but in the OS apps, the spinner does not go over the content).Here's an image of the problem: https://www.dropbox.com/s/4qk6qjrdlapsvz0/IMG_0074.JPGHere's how I set up the RefreshController in ViewDidLoad.
refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refresh2)
forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:refreshControl];
self.collectionView.alwaysBounceVertical = YES;
有人知道如何让微调器位于 CollectionViewController 后面吗?谢谢
Anyone know how to make the spinner go behind the CollectionViewController? Thanks
推荐答案
我也遇到了这个问题并且想通了,所以我想我会分享.我所做的是强制它到 UICollectionView 的后面.我已经尝试了其他的东西,比如 sendSubViewToBack 和设置 UICollectionViewCell 的 zIndex 但它没有用.但是下面确实有效,我在 iOS 6+ 上进行了测试:
I had this issue as well and figured it out so I thought I would share. what I did was force it to the back of the UICollectionView. I had tried other things like sendSubViewToBack and setting the zIndex of the UICollectionViewCell but it didn't work. However below did work and I tested on iOS 6+:
refreshControl.layer.zPosition = -1;
对于 iOS 6,添加:
For iOS 6, add this:
refreshControl.userInteractionEnabled = NO;
这篇关于UIRefreshController 遍历 UICollectionView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!