gpt4 book ai didi

ios - 点击手势隐藏导航栏、标签栏和状态栏

转载 作者:可可西里 更新时间:2023-11-01 05:36:09 29 4
gpt4 key购买 nike

我正在尝试在我的 WebView 上实现点击手势来隐藏/显示导航栏、标签栏和状态栏。我有导航栏的隐藏/显示工作正常,我可以隐藏状态栏但不能让它显示出来。选项卡栏项目被隐藏,但栏仍然存在。有人可以帮忙吗?

- (void)toggleBars:(UITapGestureRecognizer *)gesture
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
BOOL statusBarHidden = YES;

BOOL barsHidden = self.navigationController.navigationBar.hidden;
[self.navigationController setNavigationBarHidden:!barsHidden animated:YES];

BOOL tabBarHidden = self.tabBarController.tabBar.hidden;
[self.tabBarController.tabBar setHidden:!tabBarHidden];
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

UIBarButtonItem *systemAction = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showMenu)];
self.navigationItem.rightBarButtonItem = systemAction;

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(toggleBars:)];
[webView addGestureRecognizer:singleTap];
singleTap.delegate = self;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}

编辑:看起来标签栏被隐藏了,但我的 webview 只是没有填充空白区域。如何在标签栏隐藏时填充空间?

最佳答案

首先,您的状态栏永远不会取消隐藏,因为您从来没有告诉过它。如所写,您的代码只是告诉状态栏在每次执行时隐藏。

[[UIApplication sharedApplication] setStatusBarHidden:![[UIApplication sharedApplication] isStatusBarHidden] withAnimation:UIStatusBarAnimationSlide];

[self.navigationController setNavigationBarHidden:!self.navigationController.navigationBar.hidden animated:YES];

另外,我不确定为什么你的标签栏没有正确隐藏的细节,但我确实找到了以下类别,它声称能够使用选项动画隐藏标签栏。

https://github.com/idevsoftware/Cocoa-Touch-Additions/tree/master/UITabBarController_setHidden

关于ios - 点击手势隐藏导航栏、标签栏和状态栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18193570/

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