我正在尝试在我的 web 视图上实现一个点击手势来隐藏/显示导航栏、标签栏和状态栏。我的导航栏的隐藏/显示工作正常,我可以隐藏状态栏但不能让它重新显示。标签栏项目被隐藏,但栏仍然存在。有人能帮忙吗?
- (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 并没有填满空白空间。隐藏标签栏时如何让它填充空间?