Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a UITabBar without UITabBarController to control a UIWebView

Tags:

ios

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?

like image 819
devth Avatar asked Jun 14 '14 16:06

devth


3 Answers

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.

like image 186
Lucas van Dongen Avatar answered Nov 12 '22 09:11

Lucas van Dongen


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.

like image 36
koen Avatar answered Nov 12 '22 08:11

koen


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.

like image 27
Manu Avatar answered Nov 12 '22 08:11

Manu