GJain
GJain

Reputation: 5093

add navigation bar to UITableViewController without using NavigationController

I am trying to add Navigation Bar to a UITableViewController without using NavigationController.

So in viewDidLoadMethod of MyUITableViewController, I create a Navigation Bar using CGRect.

UINavigationBar * navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 30, 320, 50)];

Then I present MyUITableViewController from MainViewController

   [self presentViewController:controller animated:YES completion:Nil];

At this point my MyUITableViewController is overlapping with NavBar

I was thinking of creating tableViewController with initWithFram(x, y, width, height) to compensate for NavBar.

But I was not sure what height I should use and how to come up with a value. Would it have the correct scroll behavior??

What is the right way? Please note at this point I do not want to use Navigation Controller.

Is it possible w/o Navigation Controller.

Upvotes: 2

Views: 407

Answers (1)

ppalancica
ppalancica

Reputation: 4277

Try not to use UITableViewController, but use simply UIViewController, add a UITableView object on it, and also implement the 2 protocols for table views.

You can resize the table view as you need, you can set its origin Y coordinate to 44 or 64 if you also need the status bar visible.

You can add a UINavigationBar object on top of it.

I hope doing this will help you solve the problem.

Upvotes: 1

Related Questions