iOS 监听设备音量调节

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_observerApplicationVolumeAction:) name:KNotificationApplicationSystemVolumeDidChange object:nil];
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

- (void)_observerApplicationVolumeAction:(NSNotification *)sender {
    if ([sender.name isEqualToString:KNotificationApplicationSystemVolumeDidChange]) {
        NSLog(@"_observerApplicationVolumeAction");
    }
}

#pragma mark  App音量调节
#define KNotificationApplicationSystemVolumeDidChange                        @"AVSystemController_SystemVolumeDidChangeNotification"


- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    NSLog(@"dealloc:%@",self);
}

你可能感兴趣的:(iOS 监听设备音量调节)