开发者

Can I have more than 1 UITabBarController?

Lets imagine the scenario:

UITabBarController - UITabBar - Tab 1: View Controller A - Tab 2: View Controller B

When I click on View Controller A I want to push another UITabBarController:

UITabBarController -UITabBar - Tab 1: View Controller 1 - Tab 2: View Controller 2 - Tab 3: View Controller 3

Is this pos开发者_如何学Pythonsible? To have a UITabBarController push another UITabBarController onto the view stack?


You can certainly do this but I would rethink your design. Selecting a UITabBar item and changing the Tab Bar itself goes against Human Interface Guidelines. Besides, in your example, how do you get back to the root view controller?

Perhaps you should use a UITableView that when you tap a cell it pushes a view controller containing a UITabBarController (technically this might go against HIG too since a tab bar should be the same throughout an entire app but I've had plenty of apps adopt this and it seems elegant). So using your example:

RootViewController: pushed as UINavigationController with a UITableView containing two cells: "cell1" & "cell2"

-Tapping on "cell1" pushes a view controller containing UITabBar(I) which contains "View Controller A" and "View Controller B."

-Tapping on "cell2" pushes a view controller containing UITabBar(II) which contains "View Controller 1," "View Controller 2," and "View Controller 3."

In each case, you get a "back" button and the UITabBar itself doesn't have to change.


Sure, I just stacked them up in interface builder. There's some frame offsetting issues, but you can see tabbars stacked up. Additionally, the tabbars unstack when other tabs are selected. I also had to make sure the first tab's view was added to the window's view and connected as an IBOutlet, but otherwise that should do it.

Can I have more than 1 UITabBarController?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜