Sid*_*shi 21 uitabbarcontroller uinavigationcontroller pushviewcontroller swift
我有一个tabBar+ NavigationViewController.选项卡栏具有带单元格的集合视图(Say view1),单元格中的push seague实现到另一个视图(Say view2).
在view2中我想要一个navBar但没有标签栏.
我试过了
self.tabBarController?.tabBar.hidden = true,
它适用于view2但是当我通过后退按钮返回view1时,选项卡仍然被隐藏(即使在我在viewDidLoad func中添加的view1类中).self.tabBarController?.tabBar.hidden = false
如何让标签栏重新出现在view1中?
我在迅速工作.
rck*_*nes 33
在viewDidload设置UIViewController hidesBottomBarWhenPushed为yes:
self.hidesBottomBarWhenPushed = YES;
Run Code Online (Sandbox Code Playgroud)
这样就UINavigationController可以隐藏标签栏.
Bru*_*uno 25
在prepareforsegue中使用
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showRecipeDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
RecipeDetailViewController *destViewController = segue.destinationViewController;
destViewController.recipeName = [recipes objectAtIndex:indexPath.row];
// Hide bottom tab bar in the detail view
destViewController.hidesBottomBarWhenPushed = YES;
}}
Run Code Online (Sandbox Code Playgroud)
=)
Mr *_*nev 21
Bruno Fernandes在Swift中的回答:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "YourSegueIdentifier" {
let destinationController = segue.destinationViewController as! YourViewController
destinationController.hidesBottomBarWhenPushed = true
}
}
Run Code Online (Sandbox Code Playgroud)
这个答案对我有用.把hidesBottomBarWhenPushed在viewDidLoad方法不起作用.
谢谢布鲁诺!
就我而言,我hidesBottomBarWhenPushed在推送目标视图控制器之前使用。
func showSecondViewController() {
let vc = SecondViewController()
vc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(vc, animated: true)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20986 次 |
| 最近记录: |