2

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.