[英]UIImagePickerController: Detecting Camera button (shutter) pressed
I would like to call a method that takes an NSNotification immediately after the user presses the camera shutter (ie when the "Preview" tab bar has the buttons "Retake" and "Use"). 我想调用一种方法,该方法在用户按下相机快门后立即执行NSNotification(即,当“ Preview”标签栏上有“ Retake”和“ Use”按钮时)。
I can't use the didFinishPickingImage method because at this time the user has already pressed the "Use" button. 我不能使用didFinishPickingImage方法,因为此时用户已经按下“使用”按钮。
I have already implemented this by cameraOverlayView property of UIImagePickerController(see comments), but I wonder whether there are quicker ways of 'observing' this action. 我已经通过UIImagePickerController的cameraOverlayView属性实现了此功能(请参阅评论),但是我想知道是否存在更快的“观察”此动作的方法。
Any ideas? 有任何想法吗?
To learn about camera button press event, you can fire a NSNotification
for it. 要了解相机按钮按下事件,您可以为其触发
NSNotification
。
// Add observer for when camera button is pressed
NSNotificationCenter.defaultCenter().addObserver(self, selector: @selector(yourFunctionToPerform), name: "_UIImagePickerControllerUserDidCaptureItem", object: nil)
Also add the following method to the ViewController
where you are creating ImagePickerViewController
: ImagePickerViewController
以下方法添加到要创建ImagePickerViewController
的ViewController
中:
-(void) yourFunctionToPerform{
//Do what you want to do on Camera button tap event
}
I was searching for this problem too, the key/name for the event is really obscure. 我也在搜索此问题,该事件的键/名称确实不清楚。
You CAN display it AFTER they choose the image. 您可以在选择图像后显示它。
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
//Display the UIAlertView
[alertView show];
//Just never use the image
}
If you don't want to use the image you really don't have to 如果您不想使用图像,则不必
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.