在横向iOS上消失MenuButton UISplitView

时间:2015-01-06 01:09:33

标签: ios objective-c uisplitviewcontroller

我正在使用Xcode为iOS开发应用程序

使用UISplitViewController我想在横向设置方向时隐藏menú按钮,我可以使用我的MasterVC(菜单),这是到目前为止的代码

-(void)splitViewController:(UISplitViewController *)svc
    willHideViewController:(UIViewController *)aViewController
         withBarButtonItem:(UIBarButtonItem *)barButtonItem
      forPopoverController:(UIPopoverController *)pc{

    //Grab a reference to the popover
    _popover            = pc;

    barButtonItem.title = [NSString fontAwesomeIconStringForEnum:FABars];
    [barButtonItem setTitleTextAttributes:TOOLBARICONTEXTATTRIBUTES forState:UIControlStateNormal];


    UINavigationItem *navItem       = self.navigationItem;
    [navItem setLeftBarButtonItem:barButtonItem animated:YES];
}

-(void)splitViewController:(UISplitViewController *)svc
    willShowViewController:(UIViewController *)aViewController
 invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem{


    //Remove the barButtonItem.
    [_navBarItem setLeftBarButtonItem:nil animated:YES];

    //Nil out the pointer to the popover.
    _popover = nil;

}



-(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation{

    if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
        return NO;
    }
    else{
        return YES;
    }

}
肖像模式上的

看起来不错

enter image description here

在横向模式下,菜单按钮仍然存在 enter image description here

但如果我按下触摸菜单按钮,则在风景中,masterVC(带菜单的视图控制器)会像在纵向模式下一样重新出现 enter image description here

然后当我触摸detailVC时,我的masterVC消失了,让我的视图变得丑陋 enter image description here

如何在横向模式下隐藏该按钮以禁用此类按钮操作

0 个答案:

没有答案