Wayde
Wayde

Reputation: 137

UITableView pull to refresh automatically

I got a UITableViewController and the data of the list is get from the server. Supporting scroll down to refresh data.

My question is when view did load. I don't want user use finger to pull it down get the data, but UITableView scroll down itself automatically and get data from server.

Edit:

Sorry, my question is there is a method named pullDownToRefresh, for example. If user use finger to pull down the tableView, the function is triggered. And now, I want to make tableview pull down by itself, and trigger the function automatically.

I also need to make tableView scrolls down. I tried beginRefreshing, but the tableView is not really scrolls down.

Upvotes: 4

Views: 5219

Answers (1)

NaveenRaghuveer
NaveenRaghuveer

Reputation: 124

If I understand your question correctly, you need to programatically display the refresh control(without finger swipe) and reload your tableView.

UIRefreshControl's "beginRefreshing" method serves your purpose.

  • Create a UIRefreshControl property in your UITableViewController
  • Call beginRefreshing method on that property whenever needed
  • call endRefereshing method when you have completed refreshing, reloading your tableView

More at this link :link

Upvotes: 4

Related Questions