2015-12-02 71 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

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