Harshal Wani
Harshal Wani

Reputation: 2349

Add Navigation Bar with title without Navigation controller on UITableViewController from Storyboard

As my screen have static options, so I created a screen with static cells from UITableViewController class instead of UIViewController

Now When I'm trying to add the Navigation bar from storyboard it never adds above UITableView. Always added at the footer of the table view.

Can we add without programmatically?

Please refer screenshot:

enter image description here

Appreciate your help!

Thanks

Upvotes: 0

Views: 804

Answers (3)

ViruMax
ViruMax

Reputation: 1218

In Storyboard, you can't add any other view at the same level of the TableView in TableViewController, so adding UINavigationBar won't work here.

You can show navigation bar using UINavigationController:

  1. In Storyboard first, select your Table View Controller.

  2. Then Open Editor menu, and select Embed In option, and choose Navigation Controller. You will get your navigation controller pointing to your tableview controller.

Upvotes: 1

Abbas Sabeti
Abbas Sabeti

Reputation: 151

A simple way is that you can embed your UITableViewController in a UINavigationController:

  1. Select your UITableViewController in the Storyboard.
  2. go to Editor => Embed In => Navigation Controller

The second solution is to add it programmatically, as you just said.

Upvotes: 0

Steve Chan
Steve Chan

Reputation: 107

To solve your problem, you can embed your UiTableViewController in a UINavigationController from storyboard.

Just add a UINavigationController on the storyboard and drag to your UITableviewController and set it as either root or push.

You dont have to manually add the UINavigationBar.

Hope this helps.

Upvotes: 0

Related Questions