我从来没有使用过UIVideoEditorController,所以我不知道从哪里开始。
当用户在我的集合视图单元格中选择视频时,我希望视图控制器弹出。
我已经知道了视频的URL,所以我只需要有人告诉我如何正确地呈现视图控制器。
到目前为止,这是我的代码
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let video = videosArray[indexPath.row]视频变量是我想让他们编辑的视频。
发布于 2017-07-23 05:02:24
试试这个:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let video = videosArray[indexPath.row] // videosArray is a list of URL instances
if UIVideoEditorController.canEditVideo(atPath: video.path) {
let editController = UIVideoEditorController()
editController.videoPath = video.path
editController.delegate = self
present(editController, animated:true)
}
}此外,您还需要添加UIVideoEditorControllerDelegate方法来删除显示的视频编辑器控制器:
extension YourViewController: UIVideoEditorControllerDelegate {
func videoEditorController(_ editor: UIVideoEditorController,
didSaveEditedVideoToPath editedVideoPath: String) {
dismiss(animated:true)
}
func videoEditorControllerDidCancel(_ editor: UIVideoEditorController) {
dismiss(animated:true)
}
func videoEditorController(_ editor: UIVideoEditorController,
didFailWithError error: Error) {
print("an error occurred: \(error.localizedDescription)")
dismiss(animated:true)
}
}https://stackoverflow.com/questions/45260431
复制相似问题