【发布时间】:2013-10-29 07:05:14
【问题描述】:
在我的应用程序中,我使用带有集合视图的刷新控件。
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds];
collectionView.alwaysBounceVertical = YES;
...
[self.view addSubview:collectionView];
UIRefreshControl *refreshControl = [UIRefreshControl new];
[collectionView addSubview:refreshControl];
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];
但是UICollectionView没有这个属性,所以必须有办法手动处理。
【问题讨论】:
标签: ios objective-c uitableview uicollectionview uirefreshcontrol