How to add loading Indicator in Footer of CollectionView in iOS

后端 未结 5 1937
迷失自我
迷失自我 2021-01-05 09:49

How can I add loading Indicator in the Footer of collection view when data is loaded for next page..?

I want to loading indicator in Footer of Collection vi

5条回答
  •  萌比男神i
    2021-01-05 10:06

    The easiest way it that add an UIView at the bottom of your ViewController add an ActivityIndicator to that view and set view's property hidden to checked, create an IBOutlet of that view, while loading data from server set outlet's property hidden=NO after data is loaded again hide the view. The same thing I've done in few of my apps using UICollectionViews or UITableView

    EDIT

    An another way is to add loading indicator in the footer of either CollectionView or tableview then make a network call in the below method

    For CollectionView:

    - (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath;
    

    And For TableView:

    - (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section;
    

    Swift 4.2

    For CollectionView:

    func collectionView(_ collectionView: UICollectionView, willDisplaySupplementaryView view: UICollectionReusableView, forElementKind elementKind: String, at indexPath: IndexPath)
    

    For TableView:

    func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int)
    

提交回复
热议问题