gpt4 book ai didi

ios - 侧面导航点击不起作用

转载 作者:行者123 更新时间:2023-11-29 12:09:06 25 4
gpt4 key购买 nike

我已经从库中实现了这个幻灯片菜单 iOS Slide Menu并使用了 uitabbarcontroller。

Home viewcontroller 有这个 slidemenu 但是点击侧导航栏滑动条菜单会出现但是点击记录任何 Action 都不会发生。而如果我在没有 tabbarcontroller 的情况下使用这个 slidemenu,它就可以正常工作。

任何人如果在 uitabbarcontroller 下使用 Storyboard在 IOS 中使用 objective-c 实现了这个滑动菜单。请分享您的答案。

最佳答案

在您的代码中,我做了一些更改,例如将 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);
}];
}

然后点击登录按钮时调用以下方法。

-(void)displayLandingScreen{
[self setupDrawers];
self.window.rootViewController = self.landingScreen;
}

以下代码用于用户点击注销

-(void)logOutPressed{
//mainTabBar
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
bundle: nil];
UITabBarController *loginTab = (UITabBarController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"mainTabBar"];

self.window.rootViewController = loginTab;
}

Also same code retrieve from the HERE.

关于ios - 侧面导航点击不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34039814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com