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

hag*_*ulu 8 iphone uiimagepickercontroller ios

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

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

我如何获得像Whatsapp这样的行为,可以编辑视频但图像不能?

mde*_*itt 1

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

  [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(imageCaptured:)
                                             name:@"_UIImagePickerControllerUserDidCaptureItem" object:nil]; 
Run Code Online (Sandbox Code Playgroud)

然后确定何时允许编辑

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