Reputation: 147
I want to create one application that read many data from json and show them in tableview. I want to create one button that when to click on it this page for a second time to be refresh and take data from json (check json again and if this json changed tableview also changed)
I dont know how create this function that refresh this page and run code at first.
please tell me about it.
Upvotes: 0
Views: 2462
Reputation: 4213
You can place a UIToolBar above the tableview. In that you can have a barbutton, to which you could give an action to fetch the data again. Once the data fetch is done, call
[self.tableview reloadData];
Upvotes: 0
Reputation: 4517
Why don't you use the Default RefreshControl provided in iPhoneSDK.
A UIRefreshControl
object provides a standard control that can be used to initiate the refreshing of a table view’s contents. You link a refresh control to a table through an associated table view controller object. The table view controller handles the work of adding the control to the table’s visual appearance and managing the display of that control in response to appropriate user gestures.
Check this to learn about its implementation : Working with UIRefreshControl
Upvotes: 0
Reputation: 1951
Put a button in header of section. I think that is the best place. In target method of that button call json and download all data. then call [self.tableView reloadData]. It will call all table methods like number of row , sections, cellForRow.
Upvotes: 1
Reputation: 374
[self.tableView reloadData]
to load more data from webserver in to table
Upvotes: 1