使标签栏按钮打开右侧菜单

时间:2014-06-07 13:25:53

标签: ios objective-c uitabbarcontroller iiviewdeckcontroller

假设我有一个包含5个ViewControllers的标签栏,以及一个左右菜单。

我的套牌ViewController将标签栏保存为ViewController的中心:

  self.tabBarController.viewControllers = @[UINAVIGATIONCONTROLLER(feedController),
                                              UINAVIGATIONCONTROLLER(myProfileController),
                                              UINAVIGATIONCONTROLLER(topTradersController),
                                              UINAVIGATIONCONTROLLER(stocksListController),
                                            //  UINAVIGATIONCONTROLLER(watchlistController),
                                            ];





    self.deckController =  [[STViewDeckController alloc] initWithCenterViewController:self.tabBarController
                                                                   leftViewController:settingsController
                                                                  rightViewController:watchlistController];

我想用标签栏按钮打开右侧菜单,而不是急剧地使tabBar推送那个ViewController。

说我想要" watchlistController" tabBar按钮打开侧面菜单,我怎么能这样做?

哦,我正在使用" IIViewDeckController" for deckController

由于

1 个答案:

答案 0 :(得分:0)

您可以使用UITableControllerDelegate和方法- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController

阻止tabBarController显示与标签关联的view / viewController

将以下内容添加到您的代码中:

self.tabBarController.delegate = self;

然后实现这个:

#pragma mark - UITabBarControllerDelegate

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    BOOL isLeft = YES;
    if (isLeft) {
        [self.deckController openLeftView];
    }
    else {
        [self.deckController openRightView];
    }

    return NO;
}

这应该适合你。