views:

320

answers:

1

I am trying to create a uitableviewcontroller as a modal viewcontroller to edit some settings. I am creating the tableviewcontroller in code and the thing i am struggling with currently is how to correctly add a navigation bar to the controller which will have a "Done" button on it that:

a) doesnt appear on top of the tableview and b) does not scroll with the tableview??

This happens when i add the navbar to the contoller with: [self.view addSubview:navigationBar]; This adds a navbar to the controller which goes on top and obscures the tables first row and also scrolls with the view?

I also thought about simply using a uiviewcontroller with a separate tableview however i like the funcitonality of automatically scrolling the tableview when editing a textfield that the tableviewcontroller gives you. Just cant figure how to setup this navbar??

thx

+1  A: 

Just create UINavigationcontroller as the modal viewcontroller, and add the tableview as its root view controller.

Jaanus
Thx, maybe i not understanding correctly but this seems similar to just using a uiviewcontroller instead of a uitableviewcontroller. I would like to use a uitableviewcontroller so i dont have to worry about scrolling/resizing the view when the user tries to edit one of the textfields which the keyboard may obscure.
Tony
@Tony: when you create the modal view controller, also create a `UINavigationController` and add the view controller to it. Then, present the navigation controller.
eman