carlos
carlos

Reputation: 2624

How can I access _tabBar instance from UITabBarController

I am trying to access the _tabBar instance from a UITabBarController. I am trying to hide the tabBar in certain situations, for this, I added an extension to UITabBarController, where I can access the _tabBar instance, and call the setHidden message. This works when compiling for the simulator, but when I compile for the device, I get the following error

"_OBJC_IVAR_$_UITabBarController._tabBar", referenced from: _OBJC_IVAR_$_UITabBarController._tabBar$non_lazy_ptr in UITabBarController+TabBar.o

What do I need to add to my compiler flags? and why does it works when compiling for the simulator.

Thanks in advance.

Upvotes: 0

Views: 1012

Answers (2)

carlos
carlos

Reputation: 2624

It is accessible since iPhone OS 3.0

Upvotes: 0

Brad The App Guy
Brad The App Guy

Reputation: 16275

According to The Docs for UITabBarController:

You should never attempt to manipulate the UITabBar object itself stored in this property. If you attempt to do so, the tab bar view throws an exception. To configure the items for your tab bar interface, you should instead assign one or more custom view controllers to the viewControllers property. The tab bar collects the needed tab bar items from the view controllers you specify.

The tab bar view provided by this property is only for situations where you want to display an action sheet using the showFromTabBar: method of the UIActionSheet class.

If you are pushing your UITAbBarController onto a navigation controller stack you can set the hidesBottomBarWhenPushed property to YES, and that will work.

There might also be another API in UITAbBarController's superclass that will do this. If not you could walk through the subview hierarchy and hide the necessary one.

Upvotes: 3

Related Questions