我已经从库iOS Slide Menu实现了这个幻灯片菜单并使用了uitabbarcontroller。
主视图控制器正在使用此幻灯片菜单但是单击侧面导航栏时会出现滑动条菜单,但是点击记录时不会发生任何操作。然而,如果我使用这个没有tabbarcontroller的幻灯片,而不是它正在工作。
任何人都可以在uitabbarcontroller下使用故事板在IOS中使用目标C实现此幻灯片菜单。请分享你的答案。
答案 0 :(得分:1)
在您的代码中,我将self.window.rootViewController
中的一些更改改为App Delegate
。
此外,我更改为SlideNavigationController
定义新UINavigationController
,然后将Storyboard Id
访问下面的代码。
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
bundle: nil];
self.landingScreen = (SlideNavigationController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"launchingNVCtr"];
还有一些代码更改为appDelegate
。
-(void)setupDrawers{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
bundle: nil];
self.landingScreen = (SlideNavigationController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"launchingNVCtr"];
LeftMenuViewController *leftMenu = (LeftMenuViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"LeftMenuViewController"];
RightMenuViewController *rightMenu = (RightMenuViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"RightMenuViewController"];
self.landingScreen = [SlideNavigationController sharedInstance];
self.landingScreen.rightMenu = rightMenu;
self.landingScreen.leftMenu = leftMenu;
self.landingScreen.menuRevealAnimationDuration = 0.18f;
// Creating a custom bar button for right menu
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
[button setImage:[UIImage imageNamed:@"gear"] forState:UIControlStateNormal];
[button addTarget:[SlideNavigationController sharedInstance] action:@selector(toggleRightMenu) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.landingScreen.rightBarButtonItem = rightBarButtonItem;
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidClose object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Closed %@", menu);
}];
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidOpen object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Opened %@", menu);
}];
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidReveal object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Revealed %@", menu);
}];
}
然后点按Log In
按钮时,请按照以下方式进行通话。
-(void)displayLandingScreen{
[self setupDrawers];
self.window.rootViewController = self.landingScreen;
}
以下代码用于点按Log out
。
-(void)logOutPressed{
//mainTabBar
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
bundle: nil];
UITabBarController *loginTab = (UITabBarController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"mainTabBar"];
self.window.rootViewController = loginTab;
}