but clicking tab item will change the name to 'Cornell Rescuer' and 'Emergency Guide'. The problem is that you have title='xxxx' in your view controller's viewDidLoad() method and it will overwrite the title you set when you initializing view controllers in AppDelegate. Try to remove either of them.
If you want to have tab bar item displaying 'Home' and 'Guide', with their navigation bar displaying 'Cornell Rescuer' and 'Emergency Guide', I would suggest you to do as followings:
into their view controllers' viewDidLoad() method. This step is not necessary but I strongly recommend you to do so because I think handle tarBarItem in their view controllers would make your code clean.
In your view controllers. Take MainTableViewController.swift for example. In viewDidLoad() method, the order you set each property should be:
self.title = "Cornell Rescuer" // This step could be omitted
self.tabBarItem = UITabBarItem(title: "Home", image: UIImage(named: "home"), tag: 1)
self.navigationItem.title = "Cornell Rescuer"
Then you will have 'Home' in your tab bar but 'Cornell Rescuer' in your navigation bar. I guess that's the way you want right? Make sure you set title at the beginning because setting it will overwrite titles in tab bar and navigation bar.
=============================================
If I understand it correctly, in your most recent commit 'trying and failing to resolve back button issue for maddening reasons', are you trying to change the title of back button to 'Guide'? If so, you may consider doing it this way:
in your MainGuideViewController.swift, add two lines of code to the method tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath):
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let guideDetailViewController = CollapsibleTableViewController()
guideDetailViewController.value = GuideText(topics[indexPath.row]).value
guideDetailViewController.title = topics[indexPath.row]
let backButton = UIBarButtonItem(title: "Guide", style:.plain, target: nil, action: nil) // new line
self.navigationItem.backBarButtonItem = backButton // new line
print(navigationItem.backBarButtonItem)
navigationController?.pushViewController(guideDetailViewController, animated: true)
tableView.deselectRow(at: indexPath, animated: true)
}
The back button should have title 'Guide' now.
The concept should be correct but I didn't test the code so I cannot guarantee anything..
If I understand your problems wrong... just ignore me because I am just jabbering...
I played with your app and it was amazing. Much better than the project I wrote lol... I do have some suggestions though.
I saw that you set names and icons for tabBarItem in your AppDelegate.swift:
but clicking tab item will change the name to 'Cornell Rescuer' and 'Emergency Guide'. The problem is that you have title='xxxx' in your view controller's viewDidLoad() method and it will overwrite the title you set when you initializing view controllers in AppDelegate. Try to remove either of them.
If you want to have tab bar item displaying 'Home' and 'Guide', with their navigation bar displaying 'Cornell Rescuer' and 'Emergency Guide', I would suggest you to do as followings:
Move this piece of code
into their view controllers' viewDidLoad() method. This step is not necessary but I strongly recommend you to do so because I think handle tarBarItem in their view controllers would make your code clean.
In your view controllers. Take MainTableViewController.swift for example. In viewDidLoad() method, the order you set each property should be:
Then you will have 'Home' in your tab bar but 'Cornell Rescuer' in your navigation bar. I guess that's the way you want right? Make sure you set title at the beginning because setting it will overwrite titles in tab bar and navigation bar.
=============================================
If I understand it correctly, in your most recent commit 'trying and failing to resolve back button issue for maddening reasons', are you trying to change the title of back button to 'Guide'? If so, you may consider doing it this way: in your MainGuideViewController.swift, add two lines of code to the method tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath):
The back button should have title 'Guide' now.
The concept should be correct but I didn't test the code so I cannot guarantee anything..
If I understand your problems wrong... just ignore me because I am just jabbering...