gpt4 book ai didi

ios - Xcode 使查看全屏,隐藏状态栏,导航栏等

转载 作者:行者123 更新时间:2023-12-01 22:22:41 25 4
gpt4 key购买 nike

我有一个 UIView现在是全屏但有status bar , navigation bar , tab bar等浮在上面,如果用户点击设备,我想隐藏并显示所有这些栏。我的问题是也许我无法确定窗口中有多少条,有没有办法通过window隐藏或显示所有现有的条? handler,不是一一隐藏吧。

现在我的代码如下:

@interface PdfViewController : UIViewController
{
BOOL _bounceBack;
BOOL _navigatioBarHidden;
BOOL _statusBarHidden;
IBOutlet UITapGestureRecognizer *_doubleTapRecognizer;
IBOutlet UITapGestureRecognizer *_singleTapRecognizer;
IBOutlet UINavigationBar *navigationBar;
}

- (IBAction)singleTap:(UITapGestureRecognizer *)sender {
NSLOGD_METADATAONLY();
_navigatioBarHidden = (_navigatioBarHidden)? NO: YES;
navigationBar.hidden = _navigatioBarHidden;
_statusBarHidden = (_statusBarHidden)? NO : YES;
[self setNeedsStatusBarAppearanceUpdate];
[sender requireGestureRecognizerToFail:_doubleTapRecognizer];
}

最佳答案

试试这个

您需要在 View Controller 中实现 prefersStatusBarHidden 方法

 - (BOOL)prefersStatusBarHidden
{
// If self.statusBarHidden is TRUE, return YES. If FALSE, return NO.
return (self.statusBarHidden) ? YES : NO;
}

然后,在您的按钮单击方法中:或使用您的选择器进行更改
- (void)clickonView:(id)sender
{
self.statusBarHidden = !self.statusBarHidden
[self.navigationController setNavigationBarHidden:self.statusBarHidden animated:YES];

// Update the status bar
[UIView animateWithDuration:0.25 animations:^{
[self setNeedsStatusBarAppearanceUpdate];
}];
}

关于ios - Xcode 使查看全屏,隐藏状态栏,导航栏等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43929662/

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