【发布时间】:2014-04-19 14:13:44
【问题描述】:
我为UICollectionView 实现了一个UIRefreshControl,以便用户可以拉动以刷新UICollectionView 中的内容。我正在 iPad 模拟器上进行测试。
在第一次尝试时,我能够提取并刷新内容。但是,我注意到加载图标仍在加载并且不会停止。在我第二次尝试加载图标仍然显示时,我拉动刷新,但它无法调用我的选择器(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 服务请求数据。我已验证该网络服务仍然有效。
【问题讨论】:
标签: ios uicollectionview uirefreshcontrol