开发者

issue with tab bar view displaying a compound view

I created a tab bar application, and I make the first tab a table. So I create a tableView controller, and go about setting the class identity of the view controller for the first tab to my tableView controller.

This works fine, and I see the contents of the table filling up the whole screen.

However, this is not what I actually want in the end goal - I would like a compound window having multiple views: - the aforementioned table - a custom view with data in it

So what I do is create a nib for this content (call it contentNib), change the tab's class from the tableView controller to a generic UIViewController, and set the nib of that tab to this new contentNib.

In this new contentNib I drag on a tableView and set File's Owner to the TableViewController. I then link the dataSource and delegate to file's owner (which is TableViewController).

Surprisingly this does not work and I receive the error:

**Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x3b0f910'**

This is bewildering to me since the file's owner is the TableViewController, which has been assigned to be both the dataSource and delegate. Does someone have either insight into my confusions, or a link to an example of how to have a compound view include a tableView?

*****update**** I see this in the Apple TableView programming guide: "Note: You should use a UIViewController subclass rather than a subclass of UITableViewController to manage a table view if the view to be managed is composed of multiple subviews, one of which is a table view. The default behavior of the UI开发者_JAVA技巧TableViewController class is to make the table view fill the screen between the navigation bar and the tab bar (if either are present)."* <----- I don't really get what this is telling me to do though... if someone can explain or point me to an example I'd be much appreciated!


The File's Owner should be a class that you instantiate. For example, in your contentNib file, you should alloc and init a table view, passing the @"contentNib" as the argument to initWithNibNamed:bundle:. It sounds like you're not doing this, as the File's Owner, while set in IB to a UITableViewController, is actually just a UIViewController.

The setting in IB is just to let IB know what outlets and actions to make available; you are responsible for providing the proper object.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜