隐藏和取消隐藏UISplitView iOS 5.1和iOS 6中的masterView

时间:2012-09-28 06:07:42

标签: iphone ios uisplitviewcontroller

我在stackoverflow中阅读了很多答案,但我很困惑,我们如何隐藏和取消隐藏masterView中的UISplitView(iOS 5.1和iOS 6)。

点击detailViewController按钮,我想显示MasterViewController,但未调用willShowViewController方法?

- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
// Called when the view is shown again in the split view, invalidating the button and popover controller.

    [self.navigationItem setLeftBarButtonItem:nil animated:YES];
    self.masterPopoverController = nil;
}

关于方法上方方向的变化调用,但我希望当用户点击detailViewController中的按钮时,应该出现MasterViewController

感谢

1 个答案:

答案 0 :(得分:0)

您可以通过以下方式实现此目的:
点击详细视图控制器中的按钮,调用以下功能。

- (void)hideUnhide
{
    doHideMasterView = !doHideMasterView // a bool variable
    if(doHideMasterView)
    {
         self.MasterViewController = [SplitViewController.viewControllers objectAtIndex:0];
         [SplitViewController.viewControllers removeObjectAtIndex:0];
    }
    else
    {
        SplitViewController.controllers = [NSArray arrayWithObjects:self.MasterViewController,self.DetailViewController,nil];
    }
}