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

Go To StackoverFlow.com

1

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

2012-04-03 22:07
by No Grabbing


3

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.

2012-04-03 22:13
by jmstone617
Thanks - After some thought I see your point @ UITableView != UITableViewController. What I want to achieve is to have the Nav controller/TableView be a subView of my Red dialog "window" (not a real window). I animate on the Red UIView and a .5 alpha full screen UIView to make a custom modal-type dialog. Works great for some other dialogs I have but I need a table where cells can be edited - No Grabbing 2012-04-03 22:28
Ok. Halt. Let's get some lingo correct so we're on the same page, plus I think knowing the correct terminology is important. What does Nav controller/TableView mean? And if you're red dialog "window" is not a real window, what is it? A UIView? On the iPhone, a UINavigationController generally controls a single view controller at a time, and that view controller is the controller for the entire contents of the screen. On iPad, this can be fudged a bit with a split view controller, for instance - jmstone617 2012-04-03 22:34
And regardless of all of this, what do you need the navigation controller for and what does that have to do with editing cells in a table view - jmstone617 2012-04-03 22:35
um... Doesn't the UITableViewController's view have to be embeded in a UINavigationController in order to use the Apple HIG method for editing cells? (Delete/Done buttons, red bar in a circle icon, etc.). The "red window" is a UIViewController in the storyboard that I load on the fly with instantiateViewControllerWithIdentifier. If I don't need to use a nav controller, that would be just fine - No Grabbing 2012-04-03 22:53
No. It's a good idea. But you can have some button or gesture put the table in editing mode by calling setEditing:animated: on the table view - jmstone617 2012-04-03 22:56
Right - just roughed that out. Doh! I was following an example and it used a UINavigationController so... -thanks for the push in the right direction - No Grabbing 2012-04-03 23:05


0

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];
2012-04-03 22:15
by benzado