Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 13th, 2012  |  syntax: None  |  size: 0.95 KB  |  views: 63  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to disable iOS System Sounds
  2. [[AVSystemController sharedAVSystemController] setVolumeTo:0 forCategory:@"Ringtone"];
  3.        
  4. - (void) setSystemVolumeLevelTo:(float)newVolumeLevel
  5. {  
  6.     Class avSystemControllerClass = NSClassFromString(@"AVSystemController");
  7.     id avSystemControllerInstance = [avSystemControllerClass performSelector:@selector(sharedAVSystemController)];
  8.  
  9.     NSString *soundCategory = @"Ringtone";
  10.  
  11.     NSInvocation *volumeInvocation = [NSInvocation invocationWithMethodSignature:
  12.                                       [avSystemControllerClass instanceMethodSignatureForSelector:
  13.                                        @selector(setVolumeTo:forCategory:)]];
  14.     [volumeInvocation setTarget:avSystemControllerInstance];
  15.     [volumeInvocation setSelector:@selector(setVolumeTo:forCategory:)];
  16.     [volumeInvocation setArgument:&newVolumeLevel atIndex:2];
  17.     [volumeInvocation setArgument:&soundCategory atIndex:3];
  18.     [volumeInvocation invoke];
  19. }
clone this paste RAW Paste Data