问题
I got an empty UICollectionView, which means the cell count is 0 in it.
I intended to do so, so when no usable data, numberOfItemsInSection
will return 0. Then user can choose to Pull to refresh if no data available. (content size is smaller than screen height, excluding the PullToRefresh arrow views)
My problem is if there is at least one cell, pull to refresh works perfect,
but when no cell, I cannot pull to refresh. I am not sure how to do it, or if the cell count impact the pullToRefresh?
My code is quite simple:
[collectionView addPullToRefreshWithActionHandler:^{
[weakSelf reloadDashboardData];
}];
collectionView.alwaysBounceVertical = YES;
collectionView.bounces = YES;
[collectionView addSubview:_emptyIndicator];
回答1:
Similar to Enable bounce/scroll for UICollectionView while no cells
The old code forgot to turn on UserInteraction in a failure call back.
Code in question above is definitely fine.
来源:https://stackoverflow.com/questions/28940364/svpulltorefresh-cannot-pull-on-an-empty-uicollectionview