美文网首页iOS性能优化iOS
iOS 监听设备音量调节

iOS 监听设备音量调节

作者: NieFeng1024 | 来源:发表于2017-04-19 15:32 被阅读262次
[[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 监听设备音量调节

    本文链接:https://www.haomeiwen.com/subject/dgchzttx.html