UITableView重新加载数据 [英] UITableView reload data

查看:100
本文介绍了UITableView重新加载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作基于导航的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 function(属于视图控制器)

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆