UIImagePickerController:检测相机按钮(快门)按下 [英] UIImagePickerController: Detecting Camera button (shutter) pressed

查看:26
本文介绍了UIImagePickerController:检测相机按钮(快门)按下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户按下相机快门后立即调用一个接收 NSNotification 的方法(即当预览"标签栏有重拍"和使用"按钮时).

I would like to call a method that takes an NSNotification immediately after the user presses the camera shutter (i.e when the "Preview" tab bar has the buttons "Retake" and "Use").

我不能使用 didFinishPickingImage 方法,因为此时用户已经按下了使用"按钮.

I can't use the didFinishPickingImage method because at this time the user has already pressed the "Use" button.

我已经通过 UIImagePickerController 的 cameraOverlayView 属性实现了这个(见评论),但我想知道是否有更快的方法来观察"这个动作.

I have already implemented this by cameraOverlayView property of UIImagePickerController(see comments), but I wonder whether there are quicker ways of 'observing' this action.

有什么想法吗?

推荐答案

要了解相机按钮按下事件,您可以为其触发 NSNotification.

To learn about camera button press event, you can fire a NSNotification for it.

// Add observer for when camera button is pressed
NSNotificationCenter.defaultCenter().addObserver(self, selector: @selector(yourFunctionToPerform), name: "_UIImagePickerControllerUserDidCaptureItem", object: nil)

还将以下方法添加到您正在创建 ImagePickerViewControllerViewController 中:

Also add the following method to the ViewController where you are creating ImagePickerViewController:

-(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.

这篇关于UIImagePickerController:检测相机按钮(快门)按下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆