我有一个应用程序,有一个标签栏和导航栏,用于正常交互.我的一个屏幕是文本的很大一部分,所以我允许用户点击全屏(有点像Photos.app).
导航栏和标签栏被隐藏,我将文本视图的框架设置为全屏.问题是,标签栏曾经是大约50px的空白区域.你可以看看是否从这个屏幕截图:
删除了死的ImageShack链接
我不确定是什么导致了这个.空白绝对不是文本视图背后的视图,因为我将它的背景颜色设置为红色只是为了确定.可能是什么导致了这个?
**更新**
我在UIWindow子类中做了一些命中测试,发现空白实际上是未记录/未发布的UILayoutContainerView.这是tabBar的父视图.我不认为建议直接操作此视图,那么如何隐藏标签栏?
**更新#2**
我在动画之前和之后检查了self.view的帧,看起来父视图没有足够大小.
全屏后,视图的框架只有411像素高.我已经尝试手动搞乱框架,并设置autoResizeMask没有运气.
****更新:这是最终结果****
- (void)toggleFullscreen {
isFullScreen = !isFullScreen; //ivar
//hide status bar & navigation bar
[[UIApplication sharedApplication] setStatusBarHidden:isFullScreen animated:YES];
[self.navigationController setNavigationBarHidden:isFullScreen animated:YES];
[UIView beginAnimations:@"fullscreen" context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:.3];
//move tab bar up/down
CGRect tabBarFrame = self.tabBarController.tabBar.frame;
int tabBarHeight = tabBarFrame.size.height;
int offset = isFullScreen ? tabBarHeight : -1 * tabBarHeight;
int tabBarY = tabBarFrame.origin.y + offset;
tabBarFrame.origin.y = tabBarY;
self.tabBarController.tabBar.frame = tabBarFrame;
//fade it in/out
self.tabBarController.tabBar.alpha = isFullScreen ? 0 : …Run Code Online (Sandbox Code Playgroud) 我试图hidesBarsOnTap用标签栏模仿UINavigationController的新功能.我已经看到很多这样的答案,或者指向设置hidesBottomBarWhenPushed一个只能完全隐藏它而不是轻敲它的viewController.
@IBAction func tapped(sender: AnyObject) {
// what goes here to show/hide the tabBar ???
}
Run Code Online (Sandbox Code Playgroud)
提前致谢
编辑:根据下面的建议我试过
self.tabBarController?.tabBar.hidden = true
Run Code Online (Sandbox Code Playgroud)
确实隐藏了tabBar(在点击时切换true/false),但没有动画.我会问这是一个单独的问题.