允许 UIImagePickerController 编辑视频但不能编辑图像

发布于 2024-12-12 06:01:13 字数 202 浏览 0 评论 0原文

Whatsapp 中上传图像或视频似乎使用 UIImagePicker

可以在该视图中编辑视频,但无法编辑图像。似乎在SDK中,allowsEditing属性决定是否允许对图像和视频进行编辑。

我怎样才能获得像Whatsapp一样的行为,其中视频可以编辑但图像不能?

Uploading an image or video in Whatsapp, seems to use a UIImagePicker.

It's possible to edit video in that view, but images can't be edited. It seems that in the SDK, the allowsEditing property determines whether editing is allowed for both images and video.

How can I get the behavior like Whatsapp, where video can be edited but images cannot?

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

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

发布评论

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

评论(2

岁月如刀 2024-12-19 06:01:13

我能够通过监听来自选择器的通知来实现此功能。在 ViewDidLoad 中注册

  [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(imageCaptured:)
                                             name:@"_UIImagePickerControllerUserDidCaptureItem" object:nil]; 

然后确定何时允许编辑

   - (void) imageCaptured:(NSNotification *)notification
   {
       if (self.pickerController.cameraCaptureMode == UIImagePickerControllerCameraCaptureModeVideo) {
            self.pickerController.allowsEditing = YES;
         }
         else{
            self.pickerController.allowsEditing = NO; 
         {
   }

I was able to achieve this functionality by listening for notifications from the picker. Sign-up in ViewDidLoad

  [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(imageCaptured:)
                                             name:@"_UIImagePickerControllerUserDidCaptureItem" object:nil]; 

Than determine when to allowing editing

   - (void) imageCaptured:(NSNotification *)notification
   {
       if (self.pickerController.cameraCaptureMode == UIImagePickerControllerCameraCaptureModeVideo) {
            self.pickerController.allowsEditing = YES;
         }
         else{
            self.pickerController.allowsEditing = NO; 
         {
   }
夜未央樱花落 2024-12-19 06:01:13

要禁止图像编辑,请设置 allowsEditing = false

要允许视频编辑,请在 UIVideoEditorController 中呈现所选视频。

或者使用您可以根据自己的喜好进行配置的自定义图像/视频选择器。

To disallow image editing set allowsEditing = false.

To allow video editing, present the picked video in a UIVideoEditorController.

Or use a custom image / video picker that you can configure to your liking.

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