4

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.

pableiros
  • 14,932
  • 12
  • 99
  • 105
Wayde
  • 137
  • 2
  • 10
  • Don't understand your question. – gran33 May 27 '14 at 06:48
  • 1
    Just invoke your method that fetches data from the server. There is no need to pull the table down – Paulw11 May 27 '14 at 06:48
  • Please show some code to make others understand your problem – Deepak Khiwani May 27 '14 at 06:49
  • This happens to me to sometimes. Try setting the contentInset in your tableView – Gustaf Rosenblad May 27 '14 at 06:57
  • Sorry, my question is there is a methond named "pullDownToRefresh", for example. If user use finger to pull sown the tableview, the function is triggered. And now, I want to make tableview pull down by itself, and trigger the function automatically. – Wayde May 27 '14 at 07:08
  • if you want this pull down to fresh called after some specific interval just disable the gesture in "pullDownToRefresh" method use nstimer in viewDidLoad() and call this new "pullDownToRefresh" . – Agent Chocks. May 27 '14 at 07:49

1 Answers1

4

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

NaveenRaghuveer
  • 124
  • 1
  • 8
  • 2
    Thanks for your comments. I also need to make tableview scrolldown. I tried "beginRefreshing", but the tableview is not really scrolldown. – Wayde May 27 '14 at 07:45
  • beginRefreshing method just animates the spinner. To make it visible you might have to programatically set the contentOffset of the tableView. – NaveenRaghuveer May 28 '14 at 06:05