问题
I am using the latest XCode 7 Beta and creating a simple iPad application using Swift programming language.
This is how I have setup my Storyboard:
- I started with a single view app template
- Then I embedded the view in a NavigationController
- I then created my "Login" view UI elements
- I then dropped a TabBarViewController onto the storyboard
- I then linked the "Login" button to the TabBarController
- Then within each view of the tabbar, I added a NavigationBarItem and set a title
When the app runs and I click the login button, I am taken to the TabBarController, but I do not see the title.
This is how my storyboard looks like:
The app runs like this (after I clicked the login button):
Any ideas why? Am I using the controls incorrectly? Or is this a bug in Xcode 7 Beta?
Here's my test project zipped: http://s000.tinyupload.com/index.php?file_id=90125200274831974206
回答1:
This issue exists even in older Xcode versions. I resolved this issue in next steps:
- Create custom class for
Sales
andCustomers
- Add
self.tabBarController!.title = "Sales or Customers"
inviewWillAppear()
method for each custom class.
回答2:
Please set title in view didload:
navigationItem.title = "title"
来源:https://stackoverflow.com/questions/32543873/xcode7-swift-ipad-app-navigationitem-title-not-showing