- (void)viewDidLoad {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChanged:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil];
}
- (void)volumeChanged:(NSNotification *)notification{
float volume = [[[notification userInfo] objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"] floatValue];
//[self innerSetVolume:volume];
}
当我按下设备上的上/下硬件音量按钮时,不会调用 volumeChanged。 有人以前遇到过这个问题吗?
PS:我的测试设备是装有 iOS 4.3 的 iPod touch,而不是 iPhone。
最佳答案
我认为您需要启动 Audio Session 服务才能触发这些通知。
关于Objective-C:没有调用 volumeChanged 甚至为 AVSystemController_SystemVolumeDidChangeNotification 添加观察者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7749030/