简体   繁体   中英

iPhone: how to create two controller in one NIB file?

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.

将您的TableViewController链接到IBOutlet,这样您就不必麻烦initWithNibName了。

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 .

文件的所有者

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.

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