0

在我的应用程序中,我尝试使用功能 [self.navigationCotroller presentModalViewController:nextVC animated:YES]; 然而,当它进入下一个视图时,子视图会占据整个屏幕(当然是这样)问题是,我如何添加引导视图返回的条形按钮?

我试过用

  1. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"back" style:UIBarButtonItemStyleDone target:self action:@selector(Go)];
    

    在函数 viewdidLoad 中,但它不起作用,没有显示栏甚至按钮

  2. UINavigationBar *bb =  [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44)];
    self.NVBar = bb;
    [self.view addSubview:bb];
    

但是,我不知道如何将 barbutton 添加到新的 navigationBar ---NVBar

你愿意给我一个解决方案吗?

4

2 回答 2

0

您需要弹出新的视图控制器才能自动包含导航栏。

在视图控制器中,您上面的代码位于,

//*** Hook up four buttons to these actions and play around with it for a 
//*** better sense of what is going on.    
//*** JSBViewController is the name of my test class
//*** You should use your ViewController class that you are currently coding so
//*** you can see the difference of pop/push versus present/dismiss inside of a            
//*** navigation controller
-(IBAction)push:(id)sender
{
  JSBViewController * viewController = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([JSBViewController class])];
  [self.navigationController pushViewController:viewController animated:YES];
}
-(IBAction)pop:(id)sender
{
  [self.navigationController popViewControllerAnimated:YES];

}
-(IBAction)present:(id)sender
{
  JSBViewController * viewController = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([JSBViewController class])];
  [self presentViewController:viewController animated:YES completion:nil];
}
-(IBAction)dismiss:(id)sender
{
  [self dismissViewControllerAnimated:YES completion:nil];
}

对于您正在寻找的行为,您将需要使用 push 方法
[self.navigationController pushViewController:viewController animated:YES];

于 2013-05-19T05:58:35.430 回答
0

如果你[self.navigationController pushViewController:picker animated:YES];用来推动你的 nextVC,那么导航栏应该保持在顶部。然后你可以用 ` [self.navigationController popViewControllerAnimated:YES]; 弹回来

使用导航栏从模态视图返回是非常规的。`

于 2013-05-19T07:05:49.343 回答