ios - 如何使用 [camera takePhoto] 并使用 UIImagePicker 进行编辑 - UIImagePickerController.allowsEditing = YES

标签 ios objective-c camera uiimagepickercontroller photos

我会觉得自己很蠢,但我到处搜索都没有找到答案。我已经能够使用默认相机的控件调出“编辑” View 。但是我在它上面放了一个叠加层,我有一个 UIButton 连接到 IBAction 拍照,看起来像 [UIImagePickerController takePicture]。

但是,即使我将允许编辑设置为是,它也完全跳过了编辑部分。还有其他命令可以调用它吗?现在,它直接进入 didFinishPickingMediaWithInfo。

    camera.sourceType = UIImagePickerControllerSourceTypeCamera;
    camera.cameraDevice = UIImagePickerControllerCameraDeviceRear;
    camera.showsCameraControls = NO;
    camera.navigationBarHidden = YES;
    camera.toolbarHidden = YES;
    camera.wantsFullScreenLayout = NO;
    camera.allowsEditing = YES;
    camera.cameraOverlayView = overlay;
    [self presentViewController:camera animated:YES completion:nil];

然后在 IBAction 中

    [camera takePicture];

最佳答案

可能重复:UIImagePickerController does not show edit screen

根据 Apple 文档中的 takePicture: 方法:

Use this method in conjunction with a custom overlay view to initiate the programmatic capture of a still image. This supports taking more than one picture without leaving the interface, but requires that you hide the default image picker controls.

Calling this method while an image is being captured has no effect. You must wait until the associated delegate object receives an imagePickerController:didFinishPickingMediaWithInfo: message before you can capture another picture.

似乎这种方法(自定义覆盖)是为了由您自己管理而配置的。即使“allowsEditing = YES”,拍摄的照片也会直接发送到imagePickerController:didFinishPickingMediaWithInfo:。

基于此,如果我们想使用我们的自定义用户界面编辑拍摄的照片,我们应该为此目的创建一个相应的自定义编辑屏幕。

关于ios - 如何使用 [camera takePhoto] 并使用 UIImagePicker 进行编辑 - UIImagePickerController.allowsEditing = YES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17184224/

相关文章:

ios - TableView 单元格删除不起作用

来自 URL 视网膜大小的 iOS 图像?

ios - IOS模拟器中的硬件加速框架是否反射(reflect)了它在真正的iphone上的作用?

ios - 如何将第二个 Controller 中的文本字段(嵌入在表格单元格中)中的字符串传递回第一个 Controller 中的标签(也嵌入在表格单元格中)?

ios - 如何快速将相机 View 扩展到全屏 - UIImagePickerController

Android:我可以从网站上拍张照片并自动上传吗?

ios - 向表中显示少量数据并在后台运行Web服务

ios - 如何在 Objective-C 中异步获取 API 数据?

iOS 解析验证用户

android - 无法将图片保存在给定位置