Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView reload data

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)

like image 201
Andrei S Avatar asked Feb 23 '11 18:02

Andrei S


People also ask

What does Tableview reload data do?

reloadData()Reloads the rows and sections of the table view.

Can I keep the same position in my Tableview After reloading the data?

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.


2 Answers

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]; 
like image 101
SPatil Avatar answered Sep 17 '22 13:09

SPatil


Try using [tableView reloadData]; (where tableView is the name of your instance variable)

like image 39
sudo rm -rf Avatar answered Sep 17 '22 13:09

sudo rm -rf