Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow UIImagePickerController to edit video but not images

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?

like image 906
hagulu Avatar asked Oct 28 '11 07:10

hagulu


2 Answers

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; 
         {
   }
like image 175
mdewitt Avatar answered Nov 06 '22 16:11

mdewitt


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.

like image 22
Manuel Avatar answered Nov 06 '22 16:11

Manuel