开发者

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

开发者 https://www.devze.com 2023-04-06 03:19 出处:网络
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.

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 initWi开发者_运维百科thNibName 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.


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 .

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

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.


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

0

精彩评论

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