简体   繁体   中英

IOS: How do I populate a UITableView which is within a nib?

I have a nib file in which there is a UILabel and a UITableView .

So I've created 2 outlets - one for the label the other one for the UITableView .

Then I've created a subclass of TableViewController which knows how to populate a UITableView the way I want to. With it I'm going to populate that my UITableView .

Then in viewDidLoad of the controller for that nib file I do

[myTableViewController setView: myTableViewOutlet]

I expect the functions numberOfRowsInsection and other such from myTableViewController will be called after that so my UITableView gest populated.

But this does not happen and my UITableView remains empty..

What do I do wrong?

Two things I can think of that might be missing:

  1. Set data source and delegate of the tableview to the controller;
  2. Call reload data method on the tableview to trigger a reload.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM