我有导航栏和标签栏的视图.我想要发生的是隐藏某个视图上的标签栏,并在用户更改视图时再次显示标签栏.
我看到一段用于隐藏标签栏的代码:
-(void)makeTabBarHidden:(BOOL)hide
{
// Custom code to hide TabBar
if ( [tabBarController.view.subviews count] < 2 ) {
return;
}
UIView *contentView;
if ( [[tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] ) {
contentView = [tabBarController.view.subviews objectAtIndex:1];
} else {
contentView = [tabBarController.view.subviews objectAtIndex:0];
}
if (hide) {
contentView.frame = tabBarController.view.bounds;
}
else {
contentView.frame = CGRectMake(tabBarController.view.bounds.origin.x,
tabBarController.view.bounds.origin.y,
tabBarController.view.bounds.size.width,
tabBarController.view.bounds.size.height - tabBarController.tabBar.frame.size.height);
}
tabBarController.tabBar.hidden = hide;
}
Run Code Online (Sandbox Code Playgroud)
来自:http://nickwaynik.com/iphone/hide-tabbar-in-an-ios-app/
我在视图中调用它,我希望隐藏标签栏
[self makeTabBarHidden:YES];
Run Code Online (Sandbox Code Playgroud)
当我在该视图上显示/隐藏它时,它工作正常但当我导航回到上一个视图时,那里的标签栏也是隐藏的.我试着打电话给在视图中的该功能viewDidUnload,viewWillDisappear,viewDidDisappear功能,但没有任何反应.当函数被调用在前面视图的情况也是如此viewDidLoad, …
有没有办法隐藏tabbar并删除剩余的空间(约50px)?
我试过了
self.tabBarController?.tabBar.hidden = true
self.extendedLayoutIncludesOpaqueBars = true
Run Code Online (Sandbox Code Playgroud)
没运气.我看到空白.
我有一个使用a UITabBarController在模式之间切换的应用程序.在某种模式下,我想隐藏标签栏,直到该模式的步骤完成.请注意,我没有使用导航控制器,所以我无法使用setHidesBottomBarWhenPushed导航控制器上的方法来隐藏标签栏.
在iOS 8之前,当我尝试使用以下命令隐藏tarbar时:
self.tabBarController.tabBar.hidden = YES
Run Code Online (Sandbox Code Playgroud)
标签栏消失,但它在屏幕底部留下了一个50像素的空白区域,标签栏曾经是.我似乎无法弄清楚如何填补该区域.用户界面中该区域中的任何内容都被剪切,无法看到.
任何想法,如果这是可能的?我真的很想远离导航控制器.
编辑:我将奖金授予约翰,因为他在答案中付出了很多努力,并且无论如何都会得到它,但仍然没有可行的解决方案.我仍在寻找答案,如果有人知道如何做到这一点,我将不胜感激.
我想在我的应用程序中添加一个"最大化"按钮,隐藏导航和标签栏.导航栏和标签栏应平滑地滑入/滑出,内部/内容视图也应以与导航栏和标签栏相同的速率展开和缩小.
我用于[self.navigationController setNavigationBarHidden: YES/NO animated: YES];导航栏并找到了这个帖子如何隐藏uitabbarcontroller以隐藏tabbar.
UITabBar类扩展:
- (void) setTabBarHidden:(BOOL)hidden animated:(BOOL)animated {
CGRect screenRect = [[UIScreen mainScreen] bounds];
float screenHeight = screenRect.size.height;
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
screenHeight = screenRect.size.width;
}
if (!hidden) {
screenHeight -= self.tabBar.frame.size.height;
}
[UIView animateWithDuration: (animated ? UINavigationControllerHideShowBarDuration : 0) animations: ^{
for (UIView* each in self.view.subviews) {
if (each == self.tabBar) {
[each setFrame: CGRectMake(each.frame.origin.x, screenHeight, each.frame.size.width, each.frame.size.height)];
} else {
[each setFrame: CGRectMake(each.frame.origin.x, each.frame.origin.y, each.frame.size.width, screenHeight)];
}
} …Run Code Online (Sandbox Code Playgroud) 我试图隐藏特定视图的标签栏,并在触摸屏幕时显示它.我希望它具有与youtube类似的效果,例如当播放视频时,播放器控件被隐藏并触摸屏幕,控件再次显示.
我在我的应用程序中实现了UITabBarController.它的代码如下:
MainCollection *mainView = [[MainCollection alloc] initWithNibName:@"MainCollection" bundle:nil];
UINavigationController *mainNav = [[UINavigationController alloc] initWithRootViewController:mainView];
mainView = (MainCollection *)mainNav.topViewController;
mainView.managedObjectContext = self.managedObjectContext;
ShowFavourites *showVC = [[ShowFavourites alloc] initWithNibName:@"ShowFavourites" bundle:nil];
UINavigationController *showNav = [[UINavigationController alloc] initWithRootViewController:showVC];
showNav.title=@"Favourites";
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UITabBarController *tabBar = [[UITabBarController alloc] init];
[tabBar setViewControllers:@[mainNav,showNav]];
[self.window setRootViewController:tabBar];
[self.window makeKeyAndVisible];
return YES;
Run Code Online (Sandbox Code Playgroud)
我的第一个屏幕是MainCollection我应该在此视图中显示tabBar.假设在未来的看法是子类别,但是,当我浏览到其他子类别,这种观点我想隐藏的TabBar然后我如何可以将其隐藏或仅删除其子类别的看法?
任何的想法?
提前致谢.
我是iPhone开发的新手,想问一下导航控制器.如何使导航控制器固定在整个应用程序上,如facebook导航栏.它始终在导航栏中显示通知,朋友和消息.
我试图将自定义视图放在titleView中,但每次导航推送新视图时它都会消失?
我正在尝试在触摸按钮时同时隐藏UITabBarController和UINavigationController.我在这里找到了一个非常好的代码片段如何隐藏uitabbarcontroller但是在尝试隐藏和动画UINavigationController和tabbarcontroller时我遇到了问题.我在互联网上发现了很多例子,当他们隐藏tabbar使用self.tabBarController.tabBar.hidden = YES但只隐藏按钮项而不是底部的黑条.
在玩了很多之后,我可以正确制作动画,因为我认为它与导航控制器的隐藏有关,这使得整个窗口的大小可以随时改变.
-(IBAction)touchImage:(id)sender {
if (isImageFullScreen) {
isImageFullScreen = NO;
[self.navigationController setNavigationBarHidden:NO animated:YES];
[UIView transitionWithView:self.view
duration:0.5
options:UIViewAnimationOptionCurveLinear
animations:^
{
hotelImageButton.frame = CGRectMake(0,20,320,92);
[self showTabBar:self.tabBarController];
}
completion:^(BOOL finished)
{
}];
} else {
isImageFullScreen = YES;
[self.navigationController setNavigationBarHidden:YES animated:YES];
[UIView transitionWithView:self.view
duration:0.5
options:UIViewAnimationOptionCurveLinear
animations:^
{
hotelImageButton.frame = CGRectMake(0,0,320,480);
[self hideTabBar:self.tabBarController];
}
completion:^(BOOL finished)
{
}];
}
Run Code Online (Sandbox Code Playgroud)
}
hideTabBar和showTabBar方法是我上面链接的其他帖子中的方法.
我也试过其他一些组合,但我不能让它看起来不错.有任何想法吗?
提前致谢.
uitabbarcontroller uinavigationcontroller uiviewanimation ios