spring
spring

Reputation: 18497

Possible to have a UINavigationController for a UITableView that doesn't fill the entire super UIView

This is on iOS5 w/ a storyboard.

I'd like to have a UINavigationController on the UITableView below but when I try the "embed in" option, it adds it to the Red UIView, not on the table itself. For lots of reasons this is not optimal. Is what I want to do not possible: to have a table subview with its own nav controller?

Oh - while I am here - what is the deal with UINavigationControllers not being able to be resized in a storyboard? I can only set "form" "page" or "full" - when I set it to "freeform" I am not able to enter any values to resize it

enter image description here

Upvotes: 1

Views: 742

Answers (2)

benzado
benzado

Reputation: 84338

UINavigationController is a view controller, not a view, so you can't embed it inside a view.

You should be able to get what you want with a little code: you can't embed it inside Xcode, but you can set up the UINavigationController and the red view separately, then write a few lines like this:

navigationController.view.frame = CGRectMake(20, 20, 280, 300);
[redView addSubview:navigationController.view];

Upvotes: 0

jmstone617
jmstone617

Reputation: 5707

For lots of reasons this is not optimal

Actually, for lots of reasons what you are trying to do makes no sense. A UINavigationController has embedded within it (in Storyboard terms) an instance of a UIViewController. In other words, the nav controller's root view controller must be a view controller. Since UITableView is a subclass of UIView, you can't embed it inside a UINavigationController. And besides, you would never want to. A UINavigationController manages a hiearchy of view controllers. What are you trying to achieve that you think you need to put a UITableView inside of a UINavigationController? What you are probably trying to achieve is to place the view controller that the table view sits on inside a UINavigationController, in which case the result you're seeing in IB is the correct result.

Upvotes: 3

Related Questions