Closed reinink closed 7 years ago
We use many native controls in the Basecamp 3 app, which also uses Turbolinks. Each tab of the UITabBarController has it's own UINavigationController. On the UINavigationController, we explicitly set the tabBarItem
property which prevents the children view controllers from changing the title. You can also implement your own VisitableViewController
and not set the viewController.title
@zachwaugh Could you expand a bit on
In the UINavigationController, we explicitly set the tabBarItem property which prevents the children view controllers from changing the title.
We've tried setting tabBarItem.title = "Foo"
in viewDidLoad
in the nav controller, but Turbolinks replaces that title. What are we missing?
We solved this by making our own VisitableViewController subclass:
import Turbolinks
class CustomVisitableViewController: VisitableViewController {
override func visitableDidRender() {
// So the tab bar item text doesn't change to the web view's title.
navigationItem.title = visitableView.webView?.title
}
}
And we made sure to use CustomVisitableViewController
instead of VisitableViewController
in our code.
Still getting familiar with Turbolinks iOS, and I've run into a situation where I'm using a native tab bar controller to create a tabbed menu in my app. I'm set it up so that when you click on a link in that tabbed menu, it loads the corresponding controller, and that controller makes a page request. Something like this:
The issue I'm running into is with the titles in the native tab bar. They use the controller name, which Turbolinks automatically sets (I'm assuming) to the current page
<title>
. This is creating weird results. For example, if I go to a "Messages" tab, and it loads my latest message, the tab now shows the title of that message:Before:
After clicking "Messages":
Would you recommend using native controls in this way? Or am I maybe going too far with them? And if this approach is fine, any thoughts on how to prevent the menu item titles from changing?
Thanks!!!