问题,同时使用presentModalViewController
问题描述:
在我的申请,我试图使用该函数 [self.navigationCotroller presentModalViewController:nextVC动画:YES]; 然而,当它进入下一个视图,子视图完成整个屏幕(当然它确实) ,问题是,我怎么能添加栏按钮导致的看法回来?问题,同时使用presentModalViewController
我曾尝试使用
-
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"back" style:UIBarButtonItemStyleDone target:self action:@selector(Go)];
在功能viewDidLoad中,但它没有工作,没有酒吧,甚至按钮显示
UINavigationBar *bb = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44)]; self.NVBar = bb; [self.view addSubview:bb];
然而,我不知道如何将barbutton添加到新的导航栏--- NVBar
你想给我一个解决方案吗?
答
您将需要弹出新的视图控制器,以便为导航栏设置为自动包括。
在视图控制器从上面的代码中,
//*** 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];
答
如果使用[self.navigationController pushViewController:picker animated:YES];
来推下你的下一个VC,那么导航栏应该保持在最上面。然后你可以用`[self.navigationController popViewControllerAnimated:YES]来回弹。
这是相当非常规使用导航栏从一个模态视图回去。 `