Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
392 views
in Technique[技术] by (71.8m points)

iphone - 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)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...