iPhone: "abuse" UITabBar to provide simple, good looking buttons

The iPhone's UITabBar can also be used to provide as a simple, good looking solution adding extra functionality to the current screen. Similar to what Android tries to solve with the menu button, which, when selected pops up a menu providing extra functionality. Since the iPhone doesn't have a menu I thought why not use a UITabBar for that, which saves you a lot of time developing your own custom solution.

UITabBar items "abused" as buttons
Each UITabBar has a UITabBarDelegate, which requires you to implement
(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
for example like this:

However, there is one little annoyance. Whenever you click a button on a UITabBar it stays selected. Which is the right thing to do, when you actually use it as a tab bar. But since we are not, we have to add a little line of code in our UITabBarDelegate method:
[self.localNavigation setSelectedItem:nil];
This line makes sure, that as soon as we select a tab item in the UITabBar it immediately gets deselected again, with the result that it appears to the user like a normal button behavior.

Warning: this solution worked perfectly for me in the past. However, Apple might reject future applications, since you're giving the UITabBar a totally different purpose as it was originally meant for.

I've just launched a new side project of mine:

Bugfender - A modern remote logger tailor-made for mobile development

It's currently free and you can sign up here: https://app.bugfender.com/signup

Any kind of feedback is more than appreciated :-)

No comments:

Post a Comment