1
votes

I'm a little bit lost. I have created a small app that is starting with a tab bar and in one of its view there's a button that should open a Navigation view that contains a table view.

In my NIB file I have put a Navigation Controller that contains a TableView Controller. I have created a sub-class called MyTableViewController which inherits from the UITableViewController. In the NIB I have configured the Custom Class of the TableViewController with my subclass MyTableViewController.

When the button of my App is tapped, I'm loading the NIB file with the initWithNibName but it returns me a UINavigationController.

How does it work to request the creation of MyTableViewController and get a pointer on it when I'm loading my NIB? Thanks,

Sébastien.

2

2 Answers

3
votes

This one has caught me out a few times.

When you do initWithNibName it will take the class from the custom class of the File's Owner, not the custom view of any objects .

File's Owner

I dont actually bother subclassing from UITableviewController any more. Just create a view controller and drag in a table view as a subview. Just make sure you hook up the data source and the delegate.

3
votes

Link your TableViewController to an IBOutlet so you don't have to mess with initWithNibName.