gpt4 book ai didi

ios - 在 iOS 8 中隐藏音量 HUD

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:17:08 25 4
gpt4 key购买 nike

在 iOS 8 之前的版本中,有一个简单的技巧可以隐藏系统卷覆盖。您只需创建一个 MPVolumeView 并将其嵌入到您的 View 层次结构中的某个位置。这记录在这里 https://stackoverflow.com/a/7888977/3943258以及许多其他 Stack Overflow 回复。

但是,我发现这个技巧在 iOS 8 中似乎不起作用。我正在竭尽全力想弄清楚如何修复它。有谁知道在 iOS 8 中是否有办法做到这一点?

需要注意的是,当我试图隐藏 HUD(音量按钮充当相机的快门)时,我正在执行此操作的应用程序有一个事件的 AVCaptureSession。不确定这是否会产生一些副作用。

最佳答案

好吧,这滥用了私有(private) API,但我发现它有效。

- (void)setVolumeHidden:(BOOL)hidden
{
NSString *str1 = @"etSystemV";
NSString *str2 = @"eHUDEnabled";
NSString *selectorString = [NSString stringWithFormat:@"s%@olum%@:forAudioCategory:", str1, str2];
SEL selector = NSSelectorFromString(selectorString);

if ([[UIApplication sharedApplication] respondsToSelector:selector]) {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIApplication instanceMethodSignatureForSelector:selector]];
invocation.selector = selector;
invocation.target = [UIApplication sharedApplication];
BOOL value = !hidden;
[invocation setArgument:&value atIndex:2];
__unsafe_unretained NSString *category = @"Ringtone";
[invocation setArgument:&category atIndex:3];
[invocation invoke];
}
}

关于ios - 在 iOS 8 中隐藏音量 HUD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26302218/

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