Embedding View Controller in Tab Bar Controller re

2019-08-17 13:24发布

I have a View Controller which is already embedded in a Navigation Controller as such:

enter image description here

The Table View Controller has a programatically added title and button which work fine:

override func viewWillAppear(_ animated: Bool) {
    navigationItem.title = "The Harrovian"
}

override func viewDidLoad() {
    super.viewDidLoad()

    navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(refresh))

I wanted to embed the Table View Controller in a Tab View Controller as such:

enter image description here

enter image description here

Now, however, the title and button of the table view have disappeared. Why? How can I fix it?

2条回答
▲ chillily
2楼-- · 2019-08-17 13:35

You are creating the architecture of the wrong app, I would first start by creating the application with the NavBarController, I would use a navigation controller for the rest of the screens, so the navigation does not conflict.

The problem you're presenting is a conflict between the two controllers

查看更多
可以哭但决不认输i
3楼-- · 2019-08-17 13:45

I know this does not respond to your question entirely, but from what I know, the practice is to first embed the tab bar controller, and then the navigation controller for each tab. That is because every tab is a different view, and you you cannot assign the same navigation to two tabs.

If that would be possible, when you would use the navigation on tab 1, you access the view that is separate from tab 2, and when you switch to tab 2, the same navigation does not apply to the view in tab 2.

查看更多
登录 后发表回答