gpt4 book ai didi

ios - 在 iPhone App 中使用 AVSystemController

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

我想以编程方式降低 iPhone 的铃声音量,我开始知道可以使用 AVSystemController,但我知道,这是一个私有(private)方法。如果我使用它,苹果会拒绝该应用程序还是请给我建议其他方法

最佳答案

- (void) setSystemVolumeLevelTo:(float)newVolumeLevel
{
Class avSystemControllerClass = NSClassFromString(@"AVSystemController");
id avSystemControllerInstance = [avSystemControllerClass performSelector:@selector(sharedAVSystemController)];

NSString *soundCategory = @"Ringtone";

NSInvocation *volumeInvocation = [NSInvocation invocationWithMethodSignature:
[avSystemControllerClass instanceMethodSignatureForSelector:
@selector(setVolumeTo:forCategory:)]];
[volumeInvocation setTarget:avSystemControllerInstance];
[volumeInvocation setSelector:@selector(setVolumeTo:forCategory:)];
[volumeInvocation setArgument:&newVolumeLevel atIndex:2];
[volumeInvocation setArgument:&soundCategory atIndex:3];
[volumeInvocation invoke];
}

关于ios - 在 iPhone App 中使用 AVSystemController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21157137/

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