UIImagePickerController:检测按下相机按钮(快门)

发布于 2024-08-19 21:18:03 字数 244 浏览 7 评论 0原文

我想调用一个在用户按下相机快门后立即获取 NSNotification 的方法(即当“预览”选项卡栏具有“重新拍摄”和“使用”按钮时)。

我无法使用 didFinishPickingImage 方法,因为此时用户已经按下了“使用”按钮。

我已经通过 UIImagePickerController 的cameraOverlayView 属性实现了这一点(参见评论),但我想知道是否有更快的方法来“观察”此操作。

有什么想法吗?

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").

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

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

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

街角卖回忆 2024-08-26 21:18:03

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

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

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

-(void) yourFunctionToPerform{

    //Do what you want to do on Camera button tap event

}

我也在寻找这个问题,事件的键/名称确实很模糊。

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)

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.

九八野马 2024-08-26 21:18:03

您可以在他们选择图像后显示它。

- (void)imagePickerController:(UIImagePickerController *)picker 
        didFinishPickingImage:(UIImage *)image
                  editingInfo:(NSDictionary *)editingInfo
{
        //Display the UIAlertView
    [alertView show];
        //Just never use the image
}

如果您不想使用该图像,则实际上不必

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文