iPhone: Show modal UITableViewController with Navigation bar

前端 未结 6 1038
温柔的废话
温柔的废话 2021-01-30 00:10

I am showing a modal view which is a UITableViewController class. For some reason it won\'t show the navigation bar when I show it. Here is my code:



        
6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-30 00:26

    Here is one way to display navigation bar for those who are using storyboards, suggested by Apple's Tutorial on Storyboard.

    Because a modal view controller doesn’t get added to the navigation stack, it doesn’t get a navigation bar from the table view controller’s navigation controller. To give the view controller a navigation bar when presented modally, embed it in its own navigation controller.

    1. In the outline view, select View Controller.
    2. With the view controller selected, choose Editor > Embed In > Navigation Controller.

提交回复
热议问题