1

我在导航到第一个视图到第二个视图时隐藏了我的标签栏,但是如何在从第二个视图弹出到第一个视图时显示它

第一眼

 -(IBAction)gotoSecondView{

   VideoDetailViewController *vdoDtlPage = [[VideoDetailViewController alloc]initWithNibName:@"VideoDetailViewController" bundle:nil];


    self.hidesBottomBarWhenPushed=YES;

    [self.navigationController pushViewController:vdoDtlPage animated:YES];
    }

从第二个视图

  -(IBAction)back:(id)sender{

   self.hidesBottomBarWhenPushed=NO;
  [self.navigationController popViewControllerAnimated:YES];

  }
4

2 回答 2

0

一种选择是使用NSNotificationCenter

看这里的答案IOS:后退两个视图

基本上,当您关闭视图时,您会向父视图控制器添加一个通知方法,您VideoDetailViewController调用该通知并运行一个方法让我们说

  -(IBAction)back:(id)sender{

    [self.navigationController popViewControllerAnimated:YES];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"showTabBar" object:nil];

  }

然后您在父视图控制器中的相关方法运行

- (void)showTabBar:(NSNotification *)notif
    {
        NSLog(@"Received Notification ");

        self.hidesBottomBarWhenPushed=NO;
}
于 2013-02-06T14:41:06.017 回答
0

self.hidesBottom... 使 navigationController 隐藏底栏,而为其设置的 VC 在堆栈上

所以不是为根隐藏它,而是为 vdoDtlPage 隐藏它

-(IBAction)gotoSecondView{
    VideoDetailViewController *vdoDtlPage = [[VideoDetailViewController alloc]initWithNibName:@"VideoDetailViewController" bundle:nil];
    vdoDtlPage.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:vdoDtlPage animated:YES];
}

然后,当您弹出 secondView 时,firstViews 再次成为顶部 VC,并且由于它具有 hidesBottomBar=No,导航控制器将再次在栏中设置动画

于 2013-02-06T14:41:21.680 回答