In iOS 5, the volume-up button will now take a photo in the camera app, and on a UIImagePickerController
instance where .showsCameraControlls == YES
. Happy days.
However, when I set showsCameraControlls
to NO
, and supply my own (which in turn triggers takePicture
method), the volume-up button will no longer work. How can I detect the volume event while the UIImagePickerController is showing?
The old way to detect volume changes was like so:
AudioSessionSetActive(true);
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(volumeChanged:)
name:@"AVSystemController_SystemVolumeDidChangeNotification"
object:nil];
I added this code to my application delegate. Strangely volumeChanged:
is not triggered until after I show the UIImagePickerController
for the first time. More importantly, it isn't triggered while the UIImagePickerController is visible (nor is the usual volume HUD shown), I guess since Apple disabled it & hijacked the event.
So once again, is there any way to detect the volume-up button event, while the UIImagePickerController
is being displayed, when using custom camera controls, for the purpose of taking a photo?
If you're wondering why I need to use custom camera controls, it is because I want the ability to take multiple photos, which the standard camera controls do not allow.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…