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

我希望在我的方向改变时隐藏UITabBar。

我看了两种方式:

框架方式

myAppDelegate.tabBarController.tabBar.frame = CGRectMake(<<bottomOfScreen>>);

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

导航控制器方式

myOtherVC.hideTabBarWhenPushed = YES;
[self.navigationController pushViewController:myOtherVC animated:NO];

可行,但对我的应用来说不是一个好的解决方案

<强>更新

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

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


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


由于

有帮助吗?

解决方案

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

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

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

其他提示

我认为你可以轻松做到的两种方式是:

  1. 将对象重新加载回tabBar控制器 - 对于要隐藏的viewControllers,将hidesBottomBarWhenPushed设置为YES。
  2. 另一种选择是在旋转手机时让您的视图成为窗口的唯一视图,然后在手机旋转后将tabBarController.view放回窗口
  3. 希望这有帮助

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top