UIRefreshController遍历UICollectionView

use*_*966 12 objective-c ios uicollectionview uirefreshcontrol

这是一个经常发生的错误,但并非总是如此.我有一个刷新控件添加到我的UICollectionView.当我刷新时,它完美地运作.但是,如果我半次刷新它甚至完全刷新,请转到应用程序中的另一个选项卡,然后返回,当我刷新时,UIRefreshControl出现在UICollectionView的一部分上.此外,它不是从零刷新微调栏开始,而是从所有加载开始(我已经在其他应用程序中注意到了这一点,但是,这很多是操作系统错误,但在操作系统应用程序中,微调器不会过去内容).以下是问题的图像:https: //www.dropbox.com/s/4qk6qjrdlapsvz0/IMG_0074.JPG以下是我在ViewDidLoad中设置RefreshController的方法.

refreshControl = [[UIRefreshControl alloc] init];

[refreshControl addTarget:self action:@selector(refresh2)

forControlEvents:UIControlEventValueChanged];

[self.collectionView addSubview:refreshControl];

self.collectionView.alwaysBounceVertical = YES;
Run Code Online (Sandbox Code Playgroud)

任何人都知道如何让微调器在CollectionViewController后面?谢谢

Hen*_*irk 25

我也遇到了这个问题并且弄清楚了,所以我想我会分享.我所做的是将它强制到UICollectionView的后面.我尝试了其他的东西,如sendSubViewToBack和设置UICollectionViewCell的zIndex,但它没有工作.但是下面的确有效,我在iOS 6+上进行了测试:

refreshControl.layer.zPosition = -1;
Run Code Online (Sandbox Code Playgroud)

对于iOS 6,添加以下内容:

refreshControl.userInteractionEnabled = NO;
Run Code Online (Sandbox Code Playgroud)