1

I am currently struggling with implementing a bottom loading indicator for my app, exactly like Instagram and Facebook has. Simply I want to show a loading indicator at the bottom (on reverse drag) just like a normal table view loading.

Here is the code that I have for the regular table view update:

var refreshControl: UIRefreshControl!

//In viewDidLoad

refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: "Refresh:", forControlEvents: UIControlEvents.ValueChanged)
tableView.addSubview(refreshControl)

In my func Refresh() I simply just fetch the data, and controls the activity indicator from there. However, how would I approach this, if I wanted to enable this in the bottom of my tableView?

Help is much appreciated.

askaale
  • 1,199
  • 1
  • 23
  • 50
  • Possible duplicate of [How can i add a activity indicator below the UITableView?](http://stackoverflow.com/questions/7953344/how-can-i-add-a-activity-indicator-below-the-uitableview) – Victor Sigler Sep 09 '16 at 21:25

3 Answers3

1

Add it to the table footer view

tableView.tableFooterView = footerView

Adding a refreshControl would be difficult. Add a UIIndicatorView to the footerview. Implement scrollViewDidScroll:

func scrollViewDidScroll(scrollView: UIScrollView) {
    if (scrollView.contentOffset.y + scrollView.frame.size.height) >= scrollView.contentSize.height {
        tableView.tableFooterView!.hidden = true
        // call method to add data to tableView
    }
}
vj9
  • 1,546
  • 1
  • 11
  • 18
1

Refresh Controller is for pulltorefresh which usually use to reload data.

Spinner at the bottom of the screen is used for pagination.

What you need to do in numberOfRows method return arraysize+1. in cellforRowAtIndexPath method check if indexpath.row > arraySize than return a cell having uiactivitycenter in the center.

Hope this will help you.

Kuntal Gajjar
  • 792
  • 6
  • 12
0

If you are getting the data from API call with pagination, which has to show in table view Then Kuntal's answer is right, in addition you can make 0 hight for cell containing indicator view when there is no more data, and after completion of reload. It is easy manage than check and return arraysize+1.