gpt4 book ai didi

iphone - 方向改变时隐藏 UITabBar

转载 作者:太空狗 更新时间:2023-10-30 03:38:19 24 4
gpt4 key购买 nike

我有一个很简单的问题,但答案并不那么简单。

我想在我的方向改变时隐藏一个 UITabBar。

我看了两种方式:

框架方式

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

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

导航 Controller 方式

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 并让当前 View 占据它的空间?


谢谢

最佳答案

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

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

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

关于iphone - 方向改变时隐藏 UITabBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1037146/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com