【发布时间】:2011-11-23 14:44:27
【问题描述】:
我需要检测用户何时按下硬件音量键,(App Store 安全方法)我尝试了很多没有运气的事情。你知道如何实现这样的功能吗?目前我正在注册通知,但他们似乎没有被调用。这是我的代码:
AudioSessionInitialize(NULL, NULL, NULL, NULL);
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
selector:@selector(volumeChanged:)
name:@"AVSystemController_SystemVolumeDidChangeNotification"
object:nil];
而接收方法是:
-(void)volumeChanged:(NSNotification *)notification{
NSLog(@"YAY, VOLUME WAS CHANGED");}
任何提示将不胜感激。
【问题讨论】:
标签: iphone ios audio avfoundation volume