相关疑难解决方法(0)

在iOS7中使用UICollectionView的UIRefreshControl

在我的应用程序中,我使用刷新控件和集合视图.

UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds];
collectionView.alwaysBounceVertical = YES;
...
[self.view addSubview:collectionView];

UIRefreshControl *refreshControl = [UIRefreshControl new];
[collectionView addSubview:refreshControl];
Run Code Online (Sandbox Code Playgroud)

iOS7有一些令人讨厌的错误,当你向下拉集合视图并且在刷新开始时不释放你的手指时,垂直contentOffset移动20-30点向下,这导致丑陋的滚动跳跃.

如果你在外面使用刷新控件,表也有这个问题UITableViewController.但是对于他们来说,可以通过将您的UIRefreshControl实例分配给UITableView名为的私有属性来轻松解决_refreshControl:

@interface UITableView ()
- (void)_setRefreshControl:(UIRefreshControl *)refreshControl;
@end

...

UITableView *tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds];
[self.view addSubview:tableView];

UIRefreshControl *refreshControl = [UIRefreshControl new];
[tableView addSubview:refreshControl];
[tableView _setRefreshControl:refreshControl];
Run Code Online (Sandbox Code Playgroud)

但是UICollectionView没有这样的属性所以必须有一些方法来手动处理它.

objective-c uitableview ios uicollectionview uirefreshcontrol

31
推荐指数
1
解决办法
1万
查看次数