Antonio A. Chavez
Antonio A. Chavez

Reputation: 1026

How to add Navigation Bar Title on iOS 13 Modal Screen in swift

when I created the UITableViewController within Modal Screen, I noticed that code refused to show on Navigation Bars with Title in the Modal Screen, but Full Screen has shows it with this code.

self.navigationItem.title = "Tip"

Do someone know any tricks that allow adding that Navigation Bar Title or Navigation Bar needs in Modal Screen supports.

Let me know if you know about this, thank you for helps. :)

Upvotes: 0

Views: 1488

Answers (1)

rs7
rs7

Reputation: 1630

If you have a navigation stack with one or more view controllers and one of those view controllers (let's call it A) presents a view controller B modally, B doesn't belong to the navigation stack. It is displayed by A rather than pushed onto the stack by the navigation controller.

If you want to show a navigation bar with your modal view controller, you have 2 options:

1.Add a navigation controller before the view controller you want to present modally:

Navigation Controller 1 -(root 1)-> View Controller A -(modal)-> Navigation Controller 2 -(root 2)-> View Controller B

  1. Or, you can install a navigation bar at the top of the modal view controller.

If you just want a navigation bar for the sake of displaying a title, use option 2, otherwise, if you need a navigation stack, use option 1.

Upvotes: 1

Related Questions