iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 点击手势以隐藏导航栏,标签栏和状态栏大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试在我的网页视图上实现点按手势以隐藏/显示导航栏,标签栏和状态栏.我隐藏/显示导航栏工作正常,我可以隐藏状态栏但不能让它显示备份.标签栏项目被隐藏但条形图仍然存在.有人能帮忙吗?

- (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 – 点击手势以隐藏导航栏,标签栏和状态栏全部内容,希望文章能够帮你解决ios – 点击手势以隐藏导航栏,标签栏和状态栏所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。