gpt4 book ai didi

iphone - 旋转设备 iPhone 时隐藏 UITabBar

转载 作者:行者123 更新时间:2023-12-03 21:12:26 26 4
gpt4 key购买 nike

有人在旋转设备时成功隐藏了 UITabbar 吗?

我在 UItabbar Controller 中有一个可以旋转的 View (因此实际上是一个旋转的选项卡)

当这种情况发生时,我希望标签栏消失......但似乎没有任何作用!

标签栏仍然可见

或者它会随着 View 一起消失

或者标签栏消失并且 View 不再旋转!

因此,如果有人成功完成了这项任务,我们将不胜感激!

谢谢

汤姆

最佳答案

抱歉回复晚了pk

我设法旋转并隐藏标签栏。

首先是子类化 UITabBarController 的情况,并包含此方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

//This allows us to get the rotation calls from any view in the tab bar
//

return [self.selectedViewController shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation];
}

然后您可以仅从所需的 View Controller 进行旋转。

隐藏标签栏:

获取对应用程序委托(delegate)和选项卡栏 Controller 的引用,然后将选项卡栏设置为隐藏:

MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
UIView *tabBar = [delegate.tabBarController.view.subviews objectAtIndex:1];
tabBar.hidden = TRUE;

希望这有帮助!

关于iphone - 旋转设备 iPhone 时隐藏 UITabBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2287708/

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