方向更改时隐藏UITabBar

Fra*_*scu 7 iphone cocoa-touch objective-c uitabbarcontroller

我有一个非常简单的问题,但答案并不那么容易.

当我的方向改变时,我想要隐藏UITabBar.

我看了两种方式:

框架方式

myAppDelegate.tabBarController.tabBar.frame = CGRectMake(<<bottomOfScreen>>);
Run Code Online (Sandbox Code Playgroud)

工作正常,但我有一个空白区域,所以尝试使用tabBarController.view.frame和myViewController.view.frame但我没有得到任何好结果.

导航控制器方式

myOtherVC.hideTabBarWhenPushed = YES;
[self.navigationController pushViewController:myOtherVC animated:NO];
Run Code Online (Sandbox Code Playgroud)

工作,但不是我的应用程序的好解决方案

更新:

[appDelegate.tabBarController.view removeFromSuperview];
[self.view removeFromSuperview]; [appDelegate.window addSubview:self.view];
self.view.frame = CGRectMake(0,0,480,320);
Run Code Online (Sandbox Code Playgroud)

工作正常,但不再自动旋转(当然,我没有更改shouldAutorotate,它总是返回YES)


如何隐藏我的tabBar并使当前视图占据其空间?


谢谢

Ben*_*jie 3

您可以将当前解决方案与以下方案结合使用:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
Run Code Online (Sandbox Code Playgroud)

来检测旋转。(我认为你将其与 view.transform = CGAffineTransformMakeRotation 结合起来以使其旋转......?)