gpt4 book ai didi

iphone - 如何检测 UIStatusBar 的隐藏和显示?

转载 作者:可可西里 更新时间:2023-11-01 04:40:14 26 4
gpt4 key购买 nike

我正在尝试检测 iPhone 的 UIStatusBar 的隐藏和显示但失败了。是否有任何解决方案可以帮助我,例如 KVO 或其他解决方案?

最佳答案

您可以观察共享 UIApplication 实例的 statusBarHidden 属性。

简单的例子:

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
// Do something here...
}

- (void)viewDidLoad
{
[super viewDidLoad];

[[UIApplication sharedApplication] addObserver:self forKeyPath:@"statusBarHidden" options:NSKeyValueObservingOptionNew context:NULL];
[[UIApplication sharedApplication] setStatusBarHidden:YES]; // Will notify the observer about the change
}

关于iphone - 如何检测 UIStatusBar 的隐藏和显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12832126/

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