i'm making a navigation based application for iphone.
one of my view controllers looks like this:
@interface NewComputerViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
so i'm using a UITableView
to show data.
when the view loads, I use a button in the top navigation bar to run a function loadStuff
load some stuff in a Dictionary.
My question: how do I repopulate the table view in that viewcontroller from that loadStuff
function (which belongs to the view controller)
reloadData()Reloads the rows and sections of the table view.
TableView does not reset scroll position. It maintains content offset even after reloadData function is called. So no need to do anything, if you want to keep pixel position.
You can always use [tableView reloadData]
method!
But if you have some data stored locally and loading new stuff from some server then you can go for:
[tableView beginUpdates]; [tableView insertRowsAtIndexPaths:*arrayOfIndexPaths* withRowAnimation:*rowAnimation*]; [tableView endUpdates];
And if you want to delete existing row you can use
[tableView beginUpdates]; [tableView deleteRowsAtIndexPaths:*arrayOfIndexPaths* withRowAnimation:*rowAnimation*]; [tableView endUpdates];
Try using [tableView reloadData];
(where tableView is the name of your instance variable)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With