Ios iPhone 5上的AVSystemController\u SystemVolumeDidChange通知

Ios iPhone 5上的AVSystemController\u SystemVolumeDidChange通知,ios,iphone-5,avcapturesession,Ios,Iphone 5,Avcapturesession,每次启动AVCaptureSession时,似乎都会触发iPhone 5上的AVSystemController\u SystemVolumeDidChangeNotification事件 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChanged:) name:@"AVSystemController_SystemVolumeDidChangeNotification" obje

每次启动AVCaptureSession时,似乎都会触发iPhone 5上的
AVSystemController\u SystemVolumeDidChangeNotification
事件

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChanged:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil];

有人知道如何解决这个问题吗?我用这个观察器通过音量按钮拍照(我知道这是一个私人API,但它的功能与默认的摄像头应用程序相同,苹果通常对此视而不见……),但只有在iPhone 5上,每次摄像头启动时才会拍照。

对不起,我无法让它正常工作。我相信苹果在iPhone5上采用这种方式是有充分理由的,但这是一个该死的麻烦

我找到的唯一解决方法是不使用它,而是使用音频会话属性侦听器方法:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //...
    AudioSessionInitialize(nil, nil, nil, nil);
    AudioSessionSetActive(YES);

    AudioSessionAddPropertyListener(kAudioSessionProperty_CurrentHardwareOutputVolume, volumeListenerCallbackIPhone, (__bridge void *)(self));
    //...
}
然后在回调中:

- (void)volumeChanged:(NSNotification *)notification
{
    NSLog(@"volumeChanged");
    // ...
}
…然后根据上下文进一步筛选事件

-肯用这个:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(volumeChanged:)
                                             name:@"AVSystemController_SystemVolumeDidChangeNotification"
                                           object:nil];
然后:

- (void)volumeChanged:(NSNotification*)notification
{
    if([[notification.userInfo objectForKey:@"AVSystemController_AudioVolumeChangeReasonNotificationParameter"] isEqualToString:@"ExplicitVolumeChange"])
    {
        float volume = [[[notification userInfo]
                         objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"]
                        floatValue];
    }
}

你还有这个问题吗?我想使用
AVSystemController\u SystemVolumeDidChangeNotification
,但我没有iPhone 5可供测试。是的,不幸的是,我尝试在iPhone 5上测试来解决这个问题,但似乎很难做到:(你找到了检测音量按钮按下的好方法吗?(除了整个音频会话侦听器方法)目前没有。我只是停用了iPhone5设备的功能AudioSessionAddPropertyListener在iOS 7.0中不受欢迎,尽管我找不到替代方法。