1

我有一个基于标签栏和导航栏的应用程序。在导航栏中,我有一个按钮,可以将我带到另一个我想隐藏标签栏的页面。当我试图通过一个按钮(不是返回栏按钮,常规按钮)返回主视图时,我无法将标签栏带回来。我确实尝试过: xxxxx.hidesBottomBarWhenPushed =NO;

这是我的一些代码:

在主视图中:

viewDidLoad:

 UIBarButtonItem *flipButton = [[UIBarButtonItem alloc]
                               initWithTitle:buttonTitle
                               style:UIBarButtonItemStylePlain
                               target:self
                               action:@selector(goToCreateEvent)]; 




-(void)goToCreateEvent{
     UIViewController *targetViewController;
     NSString *viewControllerName = @"CreateAnEventViewController";
     targetViewController = [[NSClassFromString(viewControllerName) alloc]   initWithNibName:viewControllerName bundle:nil];
     targetViewController.hidesBottomBarWhenPushed =YES; //Hides the tab bar
     [self.navigationController pushViewController:targetViewController animated:YES];

 }

在另一个视图中:

-(IBAction)save:(id)sender
 {
    [summary resignFirstResponder];
    [agenda resignFirstResponder];

    FeedViewController *aboutViewCont = [[FeedViewController alloc] init];

    aboutViewCont.hidesBottomBarWhenPushed =NO; //trying to bring back the tab bar

    [[self navigationController] pushViewController:aboutViewCont animated:NO];

  }

谢谢!约西

4

2 回答 2

1

这简单地解决它: [[self navigationController] popToRootViewControllerAnimated:YES];

于 2013-10-24T21:36:57.150 回答
0

在设置为喜欢下面的viewWillAppear:方法..FeedViewControllerhidesBottomBarWhenPushedNO

-(void)viewWillAppear:(BOOL)animated{
    self.hidesBottomBarWhenPushed = NO;
}

更新:也试试这个..

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

    CGRect r = self.tabBarController.view.frame;
    r.size.height +=self.tabBarController.tabbar.frame.size.height;
    self.tabBarController.view.frame = r;
}

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    self.tabBarController.view.frame = CGRectMake(0, 0, 320, 480); //for iPhone portrait
}

在您的课程中使用上述方法,FeedViewController也只需从您的代码中注释此波纹管..

targetViewController.hidesBottomBarWhenPushed =YES;//comment this..
于 2013-05-22T12:55:43.810 回答