我为UICollectionView
实施了UIRefreshControl
,这样用户就可以拉动以刷新UICollectionView
中的内容。我正在iPad模拟器上测试。UIRefreshControl加载图标仍在加载
第一次尝试时,我可以拉取和刷新内容。但是,我注意到加载图标仍在加载并且不停止。在我第二次尝试加载图标仍然显示时,我拉起来刷新,但它没有打电话给我的选择器(refreshCollectionAction
)。
这里是我做过什么:
-(void)viewDidLoad
{
// Do any additional setup after loading the view.
[super viewDidLoad];
// Register collectionView pull down to refresh
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refreshCollectionAction)
forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:refreshControl];
self.collectionView.alwaysBounceVertical = YES;
.....
}
-(void)refreshCollectionAction
{
NSLog(@"refresh collection action");
// Empty product Items Array
[[ProductStore getInstance] emptyProductInStore];
NSInteger numOfProductInStore = [[[ProductStore getInstance] allProductItems] count];
if (numOfProductInStore <= 0) {
// Fetch data from webservice and reload collectionView
[self fetchFeed:@""];
}
}
我错过了一些配置? fetchFeed
将向Web服务请求数据。我已经证实,web服务仍然有效。
Добрыйдень。来自新加坡。非常感谢你。它现在正在工作。我会在一段时间后发布我的解决方案。 – nuttynibbles
:)如果它解决了您的问题,然后将其标记为答案。 –