我想为应用添加DDMenuController和标签栏viewcontroller。 我无法添加两者,所以请帮我解决这个问题。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
HomeViewController *mainViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
navigationController.delegate = self;
DDMenuController *rootController = [[DDMenuController alloc] initWithRootViewController:navigationController];
_menuController = rootController;
MenuListViewController *menuController = [[MenuListViewController alloc]init];
rootController.rightViewController = menuController;
TabbarViewController *tabBarVC = [[TabbarViewController alloc] init];
tabBarVC.viewControllers = [NSArray arrayWithObjects:rootController, nil];
if ([tabBarVC respondsToSelector:@selector(willAppearIn:)])
{
[tabBarVC performSelector:@selector(willAppearIn:) withObject:navigationController];
}
self.window.rootViewController = tabBarVC;
[self.window makeKeyAndVisible];
return YES;
}
感谢您的帮助...
答案 0 :(得分:0)
我认为这会有所帮助。
首先创建标签栏而不是添加DDMenuController,最后添加到窗口的根视图
这可能有用。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
HomeViewController *mainViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
navigationController.delegate = self;
TabbarViewController *tabBarVC = [[TabbarViewController alloc] init];
tabBarVC.viewControllers = [NSArray arrayWithObjects:rootController, nil];
if ([tabBarVC respondsToSelector:@selector(willAppearIn:)])
{
[tabBarVC performSelector:@selector(willAppearIn:) withObject:navigationController];
}
DDMenuController *rootController = [[DDMenuController alloc] initWithRootViewController:tabBarVC];
_menuController = rootController;
MenuListViewController *menuController = [[MenuListViewController alloc]init];
rootController.rightViewController = menuController;
self.window.rootViewController = rootController;
[self.window makeKeyAndVisible];
return YES;
}
编辑:
这是视图控制器序列。
navigationViewController - > rootViewController - >主ViewController(默认为你)
tabbar - > rootViewController - > navigationViewController(如果你想要很多,你可以在tabbarViewController中放置很多视图)
manuViewController(由DDMenuController在右侧显示)
DDMenuController - > rootViewController - >的TabBar
和
DDMenuController - > rightController - > manuViewController
窗口 - > rootviewcontroller - > DDMenuController