【问题标题】:Side Navigation Click Not Working侧边导航点击不起作用
【发布时间】:2015-12-02 10:01:30
【问题描述】:

我已经从库 iOS Slide Menu 中实现了这个幻灯片菜单,并使用了 uitabbar 控制器。

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

任何人如果在 uitabbar 控制器下使用情节提要在 IOS 中使用目标 C 实现此幻灯片菜单。请分享您的答案。

【问题讨论】:

标签: ios github storyboard uitabbarcontroller


【解决方案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;
}

Also same code retrieve from the HERE.

【讨论】:

  • 还没有问题。我不需要那些登录视图控制器,我在这个新版本中所做的第一个标签栏部分需要直接主页。现在侧面导航点击是不可行的问题。 dropbox.com/s/34qzh8pyg78hyok/iOS-Slide.zip?dl=0
  • @CJIOSDeveloper 伙计,这是您的项目流程,但我根据您的需要创建。
  • 但是我做了必要的更改并且没有工作。你能提出任何替代方案吗?
  • 在这种情况下,您可以看到当单击侧栏行时,只有导航关闭并且视图控制器没有重新加载。
  • 你有没有看过 IOSslide 菜单应用程序左视图控制器中的 didselect 行委托,单击时未加载新控制器。
猜你喜欢
  • 2020-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-12
  • 1970-01-01
  • 2018-04-10
  • 2022-11-05
  • 2015-12-03
相关资源
最近更新 更多