我正在尝试实现MMDrawer来实现左抽屉,但只在一个视图控制器中,它不是根控制器。 点击登录按钮我应该能够重定向到另一个具有左抽屉和中心视图的视图控制器
与Using MMDrawer only in sub navigation view
几乎相似的问题-(void) signInButtonListener:(UIButton *)button{
UIViewController * leftDrawer = [[leftDrawerViewController alloc] init];
UIViewController * center = [[centreViewController alloc] init];
MMDrawerController * drawerController = [[MMDrawerController alloc]
initWithCenterViewController:center
leftDrawerViewController:leftDrawer
rightDrawerViewController:nil];
[drawerController setShowsShadow:NO];
[drawerController setRestorationIdentifier:@"MMDrawer"];
[drawerController setMaximumRightDrawerWidth:200.0];
[drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
[drawerController
setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
MMDrawerControllerDrawerVisualStateBlock block;
block = [[MMExampleDrawerVisualStateManager sharedManager]
drawerVisualStateBlockForDrawerSide:drawerSide];
if(block){
block(drawerController, drawerSide, percentVisible);
}
}];
landingPageViewController *landingPageController = [UBNLandingPageViewController new];
[myNavigator pushViewController:drawerController animated:YES];
}
答案 0 :(得分:0)
在AppDelegate.h中
@property (strong, nonatomic) MMDrawerController *drawer;
在AppDelegate.m文件中 内:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIStoryboard *mainstory=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController * leftDrawer = [mainstory instantiateViewControllerWithIdentifier:@"MenuTableViewController"];
UIViewController * center = [mainstory instantiateViewControllerWithIdentifier:@"HomeViewController"];
UINavigationController *leftnav=[[UINavigationController alloc]initWithRootViewController:leftDrawer];
UINavigationController *homnav=[[UINavigationController alloc]initWithRootViewController:center];
//drawer is the object for MMDrawerController
drawer=[[MMDrawerController alloc]initWithCenterViewController:homnav leftDrawerViewController:leftnav rightDrawerViewController:nil];
//不要写
_window.rootViewController = drawController; [_window makeKeyAndVisible]; 如果你写的话,请注释这些行。
在你的LoginButtonAction
中导入AppDelegate.h文件并在这些行中写入,然后你将获得中心视图作为下一页。
AppDelegate *app=(AppDelegate *)[[UIApplication sharedApplication]delegate];
app.window.rootViewController = app.drawer;
[app.window makeKeyAndVisible];