hiding TabBar when rotating iPhone device to landscape(将 iPhone 设备旋转为横向时隐藏 TabBar)
问题描述
这就是我所拥有的:一个处理不同 UIViewControllers 的 UITabBarController.在其中一个 UIViewController 中,我试图切换设备旋转到横向时显示的视图.重要的部分是横向显示的视图必须占据整个屏幕......
So here is what i have: A UITabBarController that handles different UIViewControllers. In one of the UIViewController i am trying to switch the view being displayed when the device rotates to landscape. the important part is that the view displayed in landscape MUST take the whole screen...
我已经正确实现了方法:
I have correctly implemented the methods :
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
事实上,我确实正确地进行了轮换,并且我的观点交换了.我什至隐藏了状态栏、导航栏和标签栏,但我在屏幕底部一直有一个空白区域,这是标签栏的位置......
In fact i do have my rotation occurring correctly, and I my views swaped. i even hide status bar, nav bar and Tab bar BUT i keep having a blank space at the bottom of the screen which is the place of the TabBar...
所以我假设设置 tabBar 的 hidden 属性不足以在整个屏幕上显示视图.我认为在 TabBarController 甚至 MainWindow 中有一些事情要做,比如我现在不需要 TabBarController".但我不知道如何正确解决这个问题.
So i am assuming that setting the hidden property of the tabBar is not enough in order to have the view on the whole screen. I think there is some stuff to do within the TabBarController or even the MainWindow to say somehting like "i don't need TabBarController now". But i do not see how to get around this problem properly.
如果有人遇到过这个问题,我将不胜感激.
If anyone has been around this issue, i would appreciate some help.
谢谢你,萨米人.
推荐答案
这对我有用.
- (void)viewDidLoad {
[super viewDidLoad];
previousRect = self.view.frame;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
{
if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
[self.navigationController setNavigationBarHidden:TRUE animated:FALSE];
[[UIApplication sharedApplication] setStatusBarHidden:TRUE animated:FALSE];
}
else
{
[self.navigationController setNavigationBarHidden:FALSE animated:FALSE];
[[UIApplication sharedApplication] setStatusBarHidden:FALSE animated:FALSE];
}
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
UIInterfaceOrientation toOrientation = self.interfaceOrientation;
if ( self.tabBarController.view.subviews.count >= 2 )
{
UIView *transView = [self.tabBarController.view.subviews objectAtIndex:0];
UIView *tabBar = [self.tabBarController.view.subviews objectAtIndex:1];
if(toOrientation == UIInterfaceOrientationLandscapeLeft || toOrientation == UIInterfaceOrientationLandscapeRight) {
transView.frame = CGRectMake(0, 0, 480, 320 );
tabBar.hidden = TRUE;
}
else
{
transView.frame = previousRect;
tabBar.hidden = FALSE;
}
}
}
这篇关于将 iPhone 设备旋转为横向时隐藏 TabBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 iPhone 设备旋转为横向时隐藏 TabBar
基础教程推荐
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01