Tag:

UIRefreshControl与iOS7中的UICollectionView

在我的应用程序中,我使用集合视图的刷新控制。 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没有这样的属性,所以必须有一些手动处理它的方法。