Allow UIImagePickerController to edit video but not images

拜拜、爱过 提交于 2019-12-23 07:47:31

问题


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?


回答1:


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; 
         {
   }



回答2:


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.



来源:https://stackoverflow.com/questions/7926259/allow-uiimagepickercontroller-to-edit-video-but-not-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!