【发布时间】:2010-11-09 18:01:13
【问题描述】:
我有一个带有标签栏和导航栏的应用程序,用于正常交互。我的一个屏幕是大部分文本,所以我允许用户点击进入全屏(有点像 Photos.app)。
导航栏和标签栏被隐藏,我将文本视图的框架设置为全屏。问题是,标签栏曾经所在的位置大约有 50 像素的空白区域。你可以从这个屏幕截图中看到:
删除了无效的 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 : 1;
//resize webview to be full screen / normal
[webView removeFromSuperview];
if(isFullScreen) {
//previousTabBarView is an ivar to hang on to the original view...
previousTabBarView = self.tabBarController.view;
[self.tabBarController.view addSubview:webView];
webView.frame = [self getOrientationRect]; //checks orientation to provide the correct rect
} else {
[self.view addSubview:webView];
self.tabBarController.view = previousTabBarView;
}
[UIView commitAnimations];
}
(请注意,我将 textview 切换为 webview,但对于原始文本视图也是如此)
【问题讨论】:
-
您的图片链接似乎已损坏。如果您仍有原始图像,请将其重新上传到 stack.imgur,或者只是编辑您的问题以使其在没有图像的情况下工作。谢谢。
标签: iphone iphone-sdk-3.0 uitextview