问题描述
我正在尝试结合 UITabBarController 和滑动侧菜单.
Im trying to combine both UITabBarController and Sliding Side Menu.
对于侧边菜单,我使用 SWRevealViewController
For Sliding Side menu, Im using SWRevealViewController
我成功创建了滑动菜单,但我无法包含我如何将 UITabBarController 与 SWRevealViewController 集成,或者是否有任何其他方式可以将 UITabBarController 与滑动侧菜单合并?
Im successful in creating the sliding menu but Im not be able to includeHow can I integrate the UITabBarController with SWRevealViewController or is there any other way through which I can incorporate UITabBarController with Sliding Side Menu?
推荐答案
好吧,你把你的标签栏控制器设置为显示视图控制器的前端控制器,所以当你显示你的后端控制器时,标签栏控制器当然会向右移动!!.
Well, you set your tab bar controller as the reveal view controller's front controller, so of course the tab bar controller goes to the right when you reveal your rear controller !!.
选项 A:
设法整合它.以下是执行此操作的步骤:
A. 向故事板添加一个新的 UIViewController.
A. Add a new UIViewController to the storyboard.
B. 从新添加的 UIViewController 中移除内容视图
B. Remove the content view from the newly added UIViewController
C. 确保在 IB 中为新添加的 UIViewController 选中是初始视图控制器".
C. Make sure "Is Initial View Controller" is checked in IB for the newly added UIViewController.
D. 将新添加的 UIViewController 的自定义类设置为 SWRevealViewController.
D. Set the custom class for the newly added UIViewController to SWRevealViewController.
E. 将其连接到您打算成为后视控制器的视图控制器 - 在 IB 中提供 seguesw_rear"标识符.这必须是一个显示控制器 segue 类型.
E. Connect it to a view controller that you intend to be the rear view controller - give the segue "sw_rear" identifier in IB. This must be a reveal controller segue type.
F. 将其连接到 UITabBarController - 在 IB 中提供 seguesw_front"标识符.这必须是一个显示控制器 segue 类型.
F. Connect it to the UITabBarController - give the segue "sw_front" identifier in IB. This must be a reveal controller segue type.
选项 B:
MainTabViewController *frontViewController = [[MainTabViewController alloc] init];
RearViewController *rearViewController = [[RearViewController alloc] init];
UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:rearViewController];
SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
revealController.delegate = self;
self.viewController = revealController;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
这篇关于无法将 UITabBarController 与侧边菜单一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!