添加pushViewController后,iOS,TabBar和NavigationBar被隐藏了

时间:2014-02-22 15:13:13

标签: ios

我想在FirstViewController和SecondViewController之间传递变量“uid”,所以我使用以下代码传递它。它成功传递了它,但问题是它隐藏了NavigationBar和TabBar!

我该如何解决?

  SecondViewController *vc2 = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
     vc2.uid = uid;
     [self.navigationController pushViewController:vc2  animated:YES];

1 个答案:

答案 0 :(得分:0)

为什么不使用storyboard segues来解决这个问题?只需在导航视图控制器上嵌入视图控制器并调用performSegueWithIdentifier功能。

只需将prepareForSegue函数添加到您的类并在那里设置uid:

- (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender
{

    if([segue.identifier isEqualToString:@"secondViewSegue"])
    {

    //**OPTION A**: If you are using Push segue

    SecondViewController *secondVC = (SecondViewController
*)segue.destinationViewController;

    //**OPTION B**: ***ELSE, If you are using a Modal segue

    UINavigationController *navController = (UINavigationController*)segue.destinationViewController;

    SecondViewController *secondVC = (SessionViewController *)navController.topViewController;

    //END OF OPTION B

    secondVc.uid = uidValue;

    }

}