Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a NavigationBar to UITableViewController programmatically?

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

like image 543
Tony Avatar asked Dec 07 '22 03:12

Tony


1 Answers

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

like image 110
Jaanus Avatar answered May 19 '23 01:05

Jaanus