将 iPhone 设备旋转至横向时隐藏 TabBar
这就是我所拥有的: 处理不同 UIViewController 的 UITabBarController。 在 UIViewController 之一中,我试图在设备旋转到横向时切换显示的视图。 重要的是,横向显示的视图必须占据整个屏幕...
我已经正确实现了这些方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
事实上,我的旋转确实正确,并且我的视图交换了。 我什至隐藏状态栏,导航栏和选项卡栏,但我在屏幕底部仍然有一个空白区域,这是选项卡栏的位置...
所以我假设设置选项卡栏的隐藏属性是不够的为了在整个屏幕上查看。 我认为在 TabBarController 甚至 MainWindow 中需要做一些事情来表达“我现在不需要 TabBarController”之类的内容。 但我不知道如何正确解决这个问题。
如果有人遇到过这个问题,我将不胜感激。
谢谢你, 萨米。
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...
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.
thank you,
Sami.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
这对我有用。
This worked for me.
这段代码工作正常,但是当我关闭以模态方式呈现的 uiviewcontroller 时,我的视图位于状态栏下方 20 像素。
我的视图位于导航控制器内,因此我在旋转之前不会隐藏它。
This code works fine but when i dismiss a uiviewcontroller which is presented modally, my view is under the status bar by 20 pixel.
My view is inside a navigationcontroller so i do not hide it before rotation.
我需要标签栏在横向视图中进入全屏模式,我尝试了上面建议的方法,使用
transView.frame = CGRectMake(0, 0, 480, 320 );
这结果是一个 hacky解决方案并提出了许多问题,例如隐藏和重新显示状态栏(退出纵向视图后重新显示时,视图会与状态栏重叠)。 我不会推荐这个。 最终对我来说完美的方法是推送一个包含横向视图的新视图控制器,并使用委托来重用原始 VC 的功能。
I needed tab bar to go into full screen mode in landscape view and I tried the approach suggested above using
transView.frame = CGRectMake(0, 0, 480, 320 );
This turned out to be a hacky solution and posed many problems such as with hiding and re-displaying the status bar (the view would overlap with the status bar when it is re-displayed after exiting portrait view). I would not recommend this. What worked for me perfectly in the end was pushing a new view controller containing the landscape view and using delegation to reuse the functionality of the original VC.
这种方法对我有用:(
仅在 iOS8 中测试。)
This approach is working for me:
(Only tested in iOS8.)
子类化您的 TabBarController 并在需要时隐藏 TabBar:
Subclass your TabBarController and hide the TabBar when needed:
也许你想使用这个
}
这不会隐藏标签栏,但会使旋转动画更平滑。
Maybe you want to use this
}
This doesn't hide the tab bar but makes the rotate animation smoother.
如果您有 UITabBarController 然后将 UINavigationController 放入其中,那么您可以使用 hidesBottomBarWhenPushed (带有一点技巧)来执行此操作。
诀窍是推动视图控制器,以便拾取
hidesBottomBarWhenPushed
标志。 您可以使用以下。If you have your UITabBarController then put a UINavigationController inside it then you can use hidesBottomBarWhenPushed (with a bit of trickery) to do this.
The trick is to push your view controller so that the
hidesBottomBarWhenPushed
flag is picked up. You can use following.