Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Tab Bar for iPhone changes tabs portrait to landscape orientation

I'm making a tab bar application and I want not only a custom bar on the bottom , but also the ability to change what the buttons are if the user is in portrait or landscape mode.

For instance, the user is holding iphone vertically = 3 tabs (a, b, c), but the user flips the phone on its side and the tab bar now populates with 2 tabs (d, e) which are aligned up/down on the left side of the screen so the user can read them.

I have looked into subclassing the UITabBarController class but feel like what I want is not possible by doing so. I want to know...

1) how can I accomplish this?

2) is making my own tab bar going to cause issues upon pushing the application to the App Store?

like image 277
Phil Baylog Avatar asked Nov 15 '22 01:11

Phil Baylog


1 Answers

I think that implementing what you describe shouldn't be a problem with the app store as long as your implementation is non-confusing and doesn't "break" standard tabbar behaviour. In other words, if it looks like a standard Apple control or is similar, it should function in a very similar way and not act 'broken' to a user who is familiar with tab bars. Apple do let you have some leeway and creativity with UI controls, if you're a bit careful about not confusing or annoying the user.

As for your implementation, subclassing UITabBarController wouldn't be a very good approach, I agree. To implement your custom tabbar, take a leaf out of Apple's book and write a UIViewController subclass which implements what you describe, based on how UITabBarController works (but avoid actually using Apple's UITabBarController in any way).

Your CustomTabBarController (let's call it that for convenience) should basically take a collection of UIViewControllers, icons and description texts for both landscape and portrait mode items. You'll need to detect rotation events in your CustomTabBarController and pass them on to the actual UIViewController currently showing -- and there will be other wiring, for example passing on the viewDidAppear messages, etc.

A good soure of inspiration and hints might be looking at other people's implementation of UIViewController aggregators. For example:

http://mattgemmell.com/2010/07/31/mgsplitviewcontroller-for-ipad

like image 181
occulus Avatar answered Dec 26 '22 11:12

occulus