Iphone 设置hidesBottomBarWhenPushed会在弹出视图控制器后使底部栏丢失
我有以下设置: 选项卡栏应用程序。 在一个选项卡上有一个导航控制器 我的工作流程: 当我将新的viewController推送到导航控制器堆栈上时,我设置了hidesBottomBarWhenPushed属性 这非常有效,当新的视图控制器滑动到位时,选项卡栏被“按下” 问题是: 但是,当我弹出此视图控制器时,根视图控制器再次显示,选项卡栏消失了 导航控制器已经扩展到填充选项卡栏留下的空间 是否需要设置属性以使选项卡栏再次可见Iphone 设置hidesBottomBarWhenPushed会在弹出视图控制器后使底部栏丢失,iphone,cocoa-touch,uikit,Iphone,Cocoa Touch,Uikit,我有以下设置: 选项卡栏应用程序。 在一个选项卡上有一个导航控制器 我的工作流程: 当我将新的viewController推送到导航控制器堆栈上时,我设置了hidesBottomBarWhenPushed属性 这非常有效,当新的视图控制器滑动到位时,选项卡栏被“按下” 问题是: 但是,当我弹出此视图控制器时,根视图控制器再次显示,选项卡栏消失了 导航控制器已经扩展到填充选项卡栏留下的空间 是否需要设置属性以使选项卡栏再次可见 我所尝试的: 手动弹出到根视图 为根视图按下HidesBottomB
我所尝试的: 手动弹出到根视图 为根视图按下HidesBottomBar时设置(重置)HidesBottomBar 调整根视图的大小 调整导航控制器视图属性的大小(只需在制表符所在的位置留下“空白”) 什么“排序”起作用:
如果将选项卡栏控制器的选定索引设置为任何其他索引,则会显示选项卡栏。所以我知道它仍然“存在”,但这对我帮助不大。我在我的应用程序中也做了类似的事情——只是打电话:
[self.navigationController popToRootViewControllerAnimated:YES];
似乎这样做的技巧和标签栏回来-不可否认,这是回应一个按钮按下,而不是导航栏弹出按钮。我似乎还记得,当使用导航栏后退按钮时,它也工作得很好
也许检查一下,您只是将单个视图控制器的hidesBottomBarWhenPushed属性设置为YES。这与我遇到的问题相同,但我找到了一个解决方案,请尝试此方法 我发现在推后立即隐藏并显示选项卡栏可以解决我们的问题
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *theItem = [items objectAtIndex:indexPath.row];
DetailController *nextController = [[DetailController alloc] initWithItem:theItem];
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:nextController animated:YES];
//
//[nextController setHidesBottomBarWhenPushed:YES];
self.hidesBottomBarWhenPushed=NO;
[nextController release];
}我也有这个问题。在错误的视图控制器上按下时,我正在设置-hidesbottombar 错误(但在您弹出前似乎有效): 对:
self.anotherViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:self.anotherViewController animated:animated];
除此之外:
[self.navigationController popToRootViewControllerAnimated:YES];
最初,当您执行self.hidesBottomBarWhenPushed=YES时代码>
当pushed=YES时,您必须更改ViewControllerToBepushd.hidesBottomBar代码>
那就行了 在带有工具栏的视图控制器弹出后出现的视图控制器中,尝试以下魔术:
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController setToolbarHidden:YES animated:YES];
}
奇怪的是,我从未设置此值,但在所需的ViewController上覆盖它:
- (BOOL) hidesBottomBarWhenPushed
{
return YES;
}
如果您使用的是
UINavigationController
,并且正在寻找在一个视图控制器中仅隐藏选项卡栏(底部栏)的方法,请将此代码放置在要隐藏选项卡栏的视图控制器中:
- (BOOL)hidesBottomBarWhenPushed {
return [self.navigationController.visibleViewController isEqual:self];
}
我尝试过的仅设置属性的其他方法在使用隐藏的选项卡栏从视图控制器中推送新的视图控制器后导致选项卡栏隐藏(即使在将属性设置为“否”之后也是如此)。swift:
self.hidesBottomBarWhenPushed = true
self.performSegueWithIdentifier("viewcontroller_details", sender: nil)
self.hidesBottomBarWhenPushed = false
Swift 3:在代码中,您必须将pushedController.HidesBottomBar设置为true 情节提要:
选择推送控制器,转到属性检查器,选择“视图控制器”下的“推送时隐藏底部栏”选项。我也有同样的问题,我无法使用此处提到的任何建议方法修复它 我想出了一个解决这个问题的方法,它工作得很好,虽然在我的例子中,可能,因为我正在使用RxSwift,这个问题似乎是一个竞争条件,所以我稍微延迟了弹出操作,并手动显示选项卡,但它也可能解决您的问题:
if self.tabBarController?.tabBar.isHidden == true {
self.tabBarController?.tabBar.isHidden = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
self.navigationController?.popViewController(animated: true)
}
} else {
self.navigationController?.popViewController(animated: true)
}
不幸的是,这不起作用。无论我如何弹出到rootView,选项卡栏仍然缺失。我已经为每个视图控制器正确设置了HidesBottomBar。为什么要为每个视图控制器设置它?这就是为什么你跳的时候看不到它!只需为要隐藏选项卡栏的viewController设置它!我的意思是,我已经根据viewController/情况明确地将其设置为是或否。并不是说我任意将它们都设置为“否”或“是”。SDK的版本是什么?os 3.0?试试这里已经回答过的[Show/Hide Tabbar on Push/pop]()非常适合只隐藏一个视图。就像一个评论:哈利路亚!谢谢,为我节省了很多时间。当您需要使选项卡栏消失并稍后在导航堆栈中重新出现时,此功能非常有效。谢谢在故事板上也很有用,谢谢!需要在目标视图控制器上勾选“按下时隐藏底部栏”。@corey floyd您能接受这个答案吗?就是那个还在帮你的人!
if self.tabBarController?.tabBar.isHidden == true {
self.tabBarController?.tabBar.isHidden = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
self.navigationController?.popViewController(animated: true)
}
} else {
self.navigationController?.popViewController(animated: true)
}