iOS 11.1 UIImagePickerController video crop start

2020-07-24 06:34发布

问题:

We are displaying a UIImagePickerController for users to choose (and crop) a video for use within our app. Recently users have been experiencing issues trying to crop videos, with the start time handle becoming almost impossible to drag.

It seems that the Photos app doesn't have this issue because the video timeline (and crop selection) is moved to the bottom of the screen.

I assume this has to do with the new notification centre gestures that were added for the iPhone X. I believe this question here is related to the issue we're experiencing.

Anyone else having this issue, or have a way to get around it? Since this is a stock UIViewController I can't see how we can get around the issue without building our own custom video picker/cropper.

回答1:

I was having the same issue and I decided to disable the UIImagePickerController editing and catch the video path in the UIImagePIckerController's didFinishPickingMediaWithInfo, and then use UIVideoEditorController to edit the video. This is a quick example:

if UIVideoEditorController.canEditVideo(atPath: videoPath) {
    let editController = UIVideoEditorController()
    editController.videoPath = videoPath
    editController.delegate = self
    present(editController, animated:true)
}

For more information about UIVideoEditorController, check Apple's documentation: https://developer.apple.com/documentation/uikit/uivideoeditorcontroller?