开发者

How do I reload a tableView contained within a UIViewController?

开发者 https://www.devze.com 2022-12-22 08:38 出处:网络
I want to reload the data within a table view that is contained on the root view of my application. The root view of my application (called RootViewController) is a UIViewController that has a corres

I want to reload the data within a table view that is contained on the root view of my application.

The root view of my application (called RootViewController) is a UIViewController that has a corresponding NIB file. I added a UITableView component to the RootViewController.xib via IB. In the header file RootViewController.h I ensure RootViewController conforms to . I have all this linked up correctly in IB and all the appropriate methods get called, viewWillAppear etc.

My question is, how can I get access to the UITableView so that I can call reloadData on it?

The following code won't work because 'self' is a UIViewController, not a UITableViewController.

[[self tableView] reloadData];

If I use the above code I get the following warning and my application crashes on startup:

'RootViewController' may not respo开发者_开发百科nd to '-tableView'


You need to add an IBOutlet to your controller and link the that outlet to the tableview within Interface Builder. The NIB loading process will reconnect these outlets, giving your controller a reference to the table view.

0

精彩评论

暂无评论...
验证码 换一张
取 消