似乎每次启动 AVCaptureSession 时都会触发 iPhone 5 上的 AVSystemController_SystemVolumeDidChangeNotification 事件。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChanged:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil];
有谁知道如何解决这个问题?我正在使用这个 Observer 通过音量按钮拍照(我知道这是一个私有(private) API,但它与默认相机应用程序的功能相同,Apple 通常视而不见......),但仅在 iPhone 上5 每次相机启动时都会拍摄一张照片。
最佳答案
使用这个:
[[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];
}
}
关于ios - iPhone 5 上的 AVSystemController_SystemVolumeDidChangeNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13799740/