点击UIBarButtonItem侧面菜单未打开

时间:2017-06-05 10:01:50

标签: ios

我正在自定义UIView.Button上开发iOS App.Add UIBarButtonItem成功添加。但是,当我点击按钮时输入选择器操作。但是侧面菜单没有打开。请提前帮助谢谢。

- (void)sideButton{
        UIImage *menuButtonImage = [UIImage imageNamed:@"menu-icon.png"];// set your image Name here
        UIButton *btnToggle = [UIButton buttonWithType:UIButtonTypeCustom];
        [btnToggle setImage:menuButtonImage forState:UIControlStateNormal];
        [btnToggle addTarget:self action:@selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
        btnToggle.frame = CGRectMake(10, 30, 25, 25);
        [_sideView addSubview:btnToggle]; //sideView is UIView

        _menuBarButton = [[UIBarButtonItem alloc] initWithCustomView:btnToggle];
        self.navigationItem.leftBarButtonItem = _menuBarButton;
    }
    - (IBAction)checkButtonTapped:(id)sender{
        SWRevealViewController *revealViewController = self.revealViewController;
        if ( revealViewController ){
            [_menuBarButton setTarget: self.revealViewController];
            [_menuBarButton setAction: @selector( revealToggle: )];
            [self.view 
        addGestureRecognizer:self.revealViewController.panGestureRecognizer];
        }
    }

0 个答案:

没有答案