0
我使用以下代碼(其工作)將iphone鈴聲音量設置爲零。我的問題是我想恢復和相同的代碼只是改變音量級別不起作用。請建議一個適當的方式來做到這一點。恢復鈴聲音量使用avsystemcontroller IOS不起作用
NSBundle *bundle = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/Celestial.framework"];
BOOL success = [bundle load];
Class avSystemControllerClass = NSClassFromString(@"AVSystemController");
id avSystemControllerInstance = [avSystemControllerClass performSelector:@selector(sharedAVSystemController)];
NSString *soundCategory = @"Ringtone";
NSInteger *newVolumeLevel = 0;
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];
我試圖設置newvolumelevel爲5 8 10,但它不工作。
P.S我知道它的私人框架和應用程序將不被批准。 :)