如何通过按钮点击打开侧面菜单不打开?

时间:2015-05-12 13:18:45

标签: ios ecslidingviewcontroller

我正在使用ECsliding控制器进行幻灯片menu.swipe gestrure在我的情况下运行良好,但是当点击按钮没有发生任何事情。

我的情况是:

在两个屏幕之后,我想要显示幻灯片菜单,所以我在第二个屏幕中设置了ECSlide,就像下面一样,一切都好。 在第三个视图控制器中,我设置了一个按钮以显示menu.Button被点击但菜单未打开。

- (void)viewWillAppear:(BOOL)animated{
    if (![self.slidingViewController.underLeftViewController isKindOfClass:[LeftViewController class]]) {
        self.slidingViewController.underLeftViewController  = [self.storyboard instantiateViewControllerWithIdentifier:@"LeftViewController"];
    }

   [self.navigationController setNavigationBarHidden:YES animated:YES];
    if ([self.checkStr isEqualToString:@"1"])
    {
        //provider
        UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
                                                                 bundle: nil];

        LeftViewController *leftMenu = (LeftViewController*)[mainStoryboard
                                                             instantiateViewControllerWithIdentifier: @"LeftViewController"];
        // Create your menu view controller
        ProfileController *leftMenuONE = (ProfileController*)[mainStoryboard
                                                                      instantiateViewControllerWithIdentifier: @"ProfileControllerID"];






        // configure top view controller
        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:leftMenuONE];

        self.slidingViewController = [ECSlidingViewController slidingWithTopViewController:navigationController];
        self.slidingViewController.underLeftViewController  = leftMenu;

        // enable swiping on the top view
        [navigationController.view addGestureRecognizer:self.slidingViewController.panGesture];

        // configure anchored layout
        self.slidingViewController.anchorLeftRevealAmount = 250.0;
        [self.navigationController pushViewController:self.slidingViewController animated:YES];

    }
    else
    {
        //user
        UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
                                                                 bundle: nil];

        LeftViewController *leftMenu = (LeftViewController*)[mainStoryboard
                                                             instantiateViewControllerWithIdentifier: @"LeftViewController"];
        // Create your menu view controller
        UserProfileController *leftMenuONE = (UserProfileController*)[mainStoryboard
                                                                      instantiateViewControllerWithIdentifier: @"UserProfileControllerID"];






        // configure top view controller
        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:leftMenuONE];

        self.slidingViewController = [ECSlidingViewController slidingWithTopViewController:navigationController];
        self.slidingViewController.underLeftViewController  = leftMenu;

        // enable swiping on the top view
        [navigationController.view addGestureRecognizer:self.slidingViewController.panGesture];

        // configure anchored layout
        self.slidingViewController.anchorLeftRevealAmount = 250.0;
        [self.navigationController pushViewController:self.slidingViewController animated:YES];

    }
}

LeftViewController是我的菜单视图控制器。

第三个视图控制器将加载基于condition.example如果string为1,它将转到一个视图控制器,否则另一个视图控制器。

Thirdview.h

- (IBAction)menuAction:(id)sender
{


        [self.slidingViewController anchorTopViewToRightAnimated:YES];

}
-(void)viewWillAppear:(BOOL)animated
{
    if (![self.slidingViewController.underLeftViewController isKindOfClass:[LeftViewController class]]) {
        self.slidingViewController.underLeftViewController  = [self.storyboard instantiateViewControllerWithIdentifier:@"LeftViewController"];
    }
}

0 个答案:

没有答案