我正在尝试在一个 iOS 应用程序中实现自定义标签栏和自定义侧边菜单,就像在新的 Facebook iOS 应用程序中一样。我尝试使用以下链接 https://github.com/mikefrederick/MFSideMenu和 https://github.com/isaacueca/3dglobe/tree/4648fed5915cef53c58f3e54efadf0f512446e59/xCode/UniversialGlobe/Classes使用 DDKCustomTabbar 类,但是当我尝试将它们都使用此代码时:
[self.window addSubview:sideMenu.view];
[self.window addSubview:tabbar.view];
tabbar 覆盖sideMenu 和对面。
最佳答案
几个快速点,
您试图将它们都添加到窗口中,这几乎肯定不是您想要的。相反,您想在窗口上设置一个 Root View Controller 。
现在快速查看这两个项目,您需要做的是创建一个菜单 View Controller ,其中标签栏 View Controller 作为中心 View Controller 。然后将菜单 View Controller 设置为窗口的 Root View Controller 。这是一个非常粗略的示例,说明您如何执行此操作。
GTabBar *tabBarViewController = [[GTabBar alloc] initWithTabViewControllers:@[<Tab View Controller>] tabItems:@[<TabBarItems>] initialTab:0];
YourLeftSideBarMenuViewController *leftMenuViewController = [[YourLeftSideBarMenuViewController alloc] init];
YourRightSideBarMenuViewController *rightMenuViewController = [[YourRightSideBarMenuViewController alloc] init];
MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
containerWithCenterViewController:tabBarViewController
leftMenuViewController:leftMenuViewController
rightMenuViewController:rightMenuViewController];
self.window.rootViewController = container;
查看菜单 MFSideMenu 项目中包含的基本演示。
我还建议阅读一些有关 UIKit 工作原理的内容,以便您了解窗口、 View 、 View Controller 等之间的区别......
Apple 有一个非常详细的指南,可以为您提供基础知识:https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AppDesignBasics/AppDesignBasics.html#//apple_ref/doc/uid/TP40007072-CH2-SW1
关于ios - 一个 iOS 应用程序中的 SideMenu 和 Tabbar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19368250/