I need Expert Advice on this implementation of UITabBarController

守給你的承諾、 提交于 2019-12-11 05:04:54

问题


I am currently in need of 8 TabBarItems, and I can show just 4 items in view. And I need to be able to scroll to the next 4 tabBarItems.

In the default behavior of the UITabBar, you normally get a 'MORE' tabbaritem for more than 5 tab bar items. I want it to be the Scroll Button in place of the MORE button.

So ~ ~If I press the scroll button (or the fifth) tabBarItem, it should display 4 more tab bar items with a back scroll button.

These are my ways of doing this - -

  1. Implementing a Scroll UITabBarItems but this would mean I have to work on the project from scratch, and this is not my best option.

  2. I can push view controller on the final tab and show a new view with 4 tab bar icons, and work on that. (Having trouble with pushing a tab bar controller from a tab bar controller)

  3. I can make present a modal view controller for the next four tabs and pop it when I press back scroll button. (Having trouble with setting up a tabbarcontroller as a present modal view controller)

  4. Removing all views from the tabBarViewController array and adding new ones when the corresponding tab is clicked. And again reloading the same tabs when previous tab is clicked. What are the complications of these ? I do not wish to disturb the rootController.

Anything else you can think of ?

Whatever approach I take, I need sliding animation between the two views.

I would appreciate it if anyone could offer expert advice on what can be done.

Thanks.


回答1:


I only see two good options:

  1. Throw tabs down the drain, accept what that eight options is too much for a tab bar. Instead go for a top level selection screen. Use a table view with a list, or a home screen like grid of options.
  2. Bite the bullet and implement your own LGInfiniteTabBarController, including a LGInfiniteTabBar, that actually have the behavior you want. There is no standard control for what you want.



回答2:


You could receive the delegate – tabBarController:didSelectViewController: and if it's an edge view controller, perform an animation and switch out your tabbarcontrollers viewcontrollers. You would have an empty viewcontroller which has a tabbar items that says 'Next' or 'Prev' or whatever, and you manage the separate arrays's of view controllers with the empty viewcontroller in whichever tabs would show more. Then just swap in the proper viewcontrollers when the user uses that tab.



来源:https://stackoverflow.com/questions/6792069/i-need-expert-advice-on-this-implementation-of-uitabbarcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!