UITableView 重载数据 [英] UITableView reload data
问题描述
我正在为 iphone 制作一个基于导航的应用程序.
i'm making a navigation based application for iphone.
我的一个视图控制器如下所示:
one of my view controllers looks like this:
@interface NewComputerViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
所以我使用 UITableView
来显示数据.
so i'm using a UITableView
to show data.
当视图加载时,我使用顶部导航栏中的按钮来运行一个函数 loadStuff
在字典中加载一些东西.
when the view loads, I use a button in the top navigation bar to run a function loadStuff
load some stuff in a Dictionary.
我的问题:如何从 loadStuff
函数(属于视图控制器)重新填充该视图控制器中的表视图
My question: how do I repopulate the table view in that viewcontroller from that loadStuff
function (which belongs to the view controller)
推荐答案
你可以随时使用[tableView reloadData]
方法!
但是,如果您在本地存储了一些数据并从某个服务器加载新内容,那么您可以:
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];
这篇关于UITableView 重载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!