2015-12-02 99 views
1

我已经实现了从库iOS Slide Menu这个幻灯片菜单,并使用uitabbarcontroller。侧面导航单击不工作

家庭viewcontroller是有这个幻灯片菜单,但点击侧面导航栏上滑动条菜单出现,但点击记录任何行动不会发生。而如果我使用这个没有tabbarcontroller的幻灯片菜单比它工作。

任何人如果在uitabbarcontroller下使用使用iOS中的目标C的故事板实现此幻灯片菜单。请分享你的答案。

+0

可以请你分享你的代码... –

+0

好吧,https://www.dropbox.com/s/ofrev4hhiyexr65/iOS-Slide-Menu.zip?dl=0 –

+0

是你想登录后需要'UITabBar'? –

回答

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.

+0

不仍然有一些问题。我不需要这些登录视图控制器,这是我在新版本中做的第一个tabbar部分的必需直接主页。现在侧面导航点击是不可行的问题。 https://www.dropbox.com/s/34qzh8pyg78hyok/iOS-Slide.zip?dl=0 –

+0

@CJIOSDeveloper Man,这是您的项目流程,但是我根据您的需要创建。 –

+0

但我做了所需的更改,但无法正常工作。你能提出任何替代方案吗? –