旋转设备 iPhone 时隐藏 UITabBar

发布于 2024-08-22 04:44:04 字数 244 浏览 4 评论 0原文

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

我在 UItabbar 控制器中有一个视图可以旋转(因此有效地旋转一个选项卡)

当发生这种情况时,我希望选项卡栏消失......但似乎没有任何效果!

要么选项卡栏仍然可见

,要么随视图一起消失

,要么选项卡栏消失并且视图不再旋转!

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

谢谢

汤姆

Has anyone successfully hidden a UITabbar when rotating the device?

I have one view in the UItabbar controller that i rotate (So effectively one tab that rotates)

When this happens i want the tab bar to disappear... but nothing seems to work!

Either the tabbar still remains visible

Or it disappears along with the view

Or the tabbar disappears and the view no longer rotates!

So if anyone has successfully accomplished this task any advice would be greatly appreciated!

Thanks

Tom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

还不是爱你 2024-08-29 04:44:04

抱歉回复晚了,

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

首先是子类化 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];
}

然后您可以仅从所需的视图控制器进行旋转。

隐藏选项卡栏:

获取应用程序委托和选项卡栏控制器的引用,然后将选项卡栏设置为隐藏:

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

希望这有帮助!

Sorry for the late reply pk

I managed to rotate and hide the tab bar.

First it was a case of subclassing the UITabBarController, and including this method:

- (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];
}

And then you can rotate from only the required view controllers.

To hide the tab bar:

Get reference to the app delegate and the Tab bar controller, and then set the tab bar to hidden:

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

Hope this helps!

傲性难收 2024-08-29 04:44:04

您是否尝试在视图控制器中的 UIDeviceOrientationDidChangeNotification 通知上添加观察者,并在此回调上执行“Hidden = true 或 false”?

我使用 MonoTouch 框架通过以下 C# 代码成功完成了此任务。

void Initialize ()
{
    NSNotificationCenter.DefaultCenter.AddObserver("UIDeviceOrientationDidChangeNotification", DeviceRotated);          
}

private void DeviceRotated(NSNotification notification)
{
    if ( notification.Name.Equals("UIDeviceOrientationDidChangeNotification") )
    {
        Console.WriteLine(UIDevice.CurrentDevice.Orientation.ToString());
        if ( UIDevice.CurrentDevice.Orientation != UIDeviceOrientation.Portrait ) 
        {
            tabBar.Hidden = true;
            //Plus some additional logic.
        }
        else
        {
            tabBar.Hidden = false;
        }
    }
}

Have you tried to add an observer on the UIDeviceOrientationDidChangeNotification notification in view controller, and do the "Hidden = true or false" on this callback?

I successfully accomplished this with the following C# code using the MonoTouch framework.

void Initialize ()
{
    NSNotificationCenter.DefaultCenter.AddObserver("UIDeviceOrientationDidChangeNotification", DeviceRotated);          
}

private void DeviceRotated(NSNotification notification)
{
    if ( notification.Name.Equals("UIDeviceOrientationDidChangeNotification") )
    {
        Console.WriteLine(UIDevice.CurrentDevice.Orientation.ToString());
        if ( UIDevice.CurrentDevice.Orientation != UIDeviceOrientation.Portrait ) 
        {
            tabBar.Hidden = true;
            //Plus some additional logic.
        }
        else
        {
            tabBar.Hidden = false;
        }
    }
}
澉约 2024-08-29 04:44:04

你真的可以隐藏 UItabbarController 中的标签栏吗?至少笔尖不允许您从底部栏下拉列表中选择任何一个。

can you actually hide the tabbar in the UItabbarController? Atleast the nib doesn't allow you to select none from the bottom bar dropdown.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文