1

I am trying to execute a method when the user presses the volume button but the "volumeChanged" line does not appear in the logs. I looked at several examples

iPhone Detect Volume Keys press.

iOS Detect system volume level change. private API or not? AVSystemController_SystemVolumeDidChangeNotification

-(void)volumeChanged{
    //do something
    NSLog(@"volumeChanged");
}

- (void)viewDidLoad {
    [super viewDidLoad];
    masterViewController = self;
    [masterViewController swipeInit];
    [masterViewController intervalPickerInit];

    // init audio session
    AudioSessionInitialize(NULL, NULL, NULL, NULL);
    AudioSessionSetActive(true);

    [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(volumeChanged:)
                                             name:@"AVSystemController_SystemVolumeDidChangeNotification"
                                           object:nil];
Community
  • 1
  • 1
Jack Shultz
  • 2,031
  • 2
  • 30
  • 53
  • I think the signature for your selector is wrong. You're calling @selector(volumeChanged:) and the method you wrote is @selector(volumeChanged) without a colon. – Dare Jun 22 '15 at 22:23
  • I have tried removing the colon and it still does not trigger volumeChanged. – Jack Shultz Jun 23 '15 at 01:43

0 Answers0