I want to use a UITabBar
to let the user navigate a single UIWebView
. Is this possible or would I be better off using a UIToolbar
? If better off using a UIToolbar
, how would I simulate the "selected" visual state of a button, the way UITabBar
natively does?
Using the platform style users are familiar with in your application is a good thing, but if you want more flexibility in where you place things and how you set up your hierarchy you might just better go with UITabBar directly and then implement the UITabBarDelegate separately.
https://developer.apple.com/library/ios/documentation/uikit/reference/UITabBar_Class/Reference/Reference.html#//apple_ref/doc/c_ref/UITabBar
I always advocate not using UITableViewController and other specialized ViewControllers like UITabBarController because separating everything avoids clutter and makes your applications more flexible.
According to Apple's docs, a UITabBar
is not intended to put in navigation tools for a single view such as your UIWebView
, but to navigate between different views. So it is better to use a UIToolBar
instead.
I had to add in the viewDidLoad() function the reference for the delegate:
self.tabBar.delegate = self
Otherwise the function func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem)
would never be called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With