SVPullToRefresh cannot pull on an empty UICollectionView

不羁的心 提交于 2019-12-11 02:16:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!