2

I have used UIVideoEditorViewController for trimming selected video. The problem is that the editorController has to be presented in popover style in iPad. When I running it on iPad, the editor view on pop over the left corner instead of the full screen. Is there any way to make the popover view in full screen size? Thanks

    if UIVideoEditorController.canEditVideoAtPath(tmp) {
        editVideoViewController = self.storyboard?.instantiateViewControllerWithIdentifier("editorVC") as! EditorViewController
        editVideoViewController.delegate = self
        editVideoViewController.videoPath = tmp
        editVideoViewController.videoMaximumDuration = 30
        editVideoViewController.videoQuality = .TypeHigh
        editVideoViewController.modalPresentationStyle = UIModalPresentationStyle.Popover

        editVideoViewController.popoverPresentationController?.sourceView = editVideoViewController.view

        self.presentViewController(editVideoViewController, animated: true, completion: nil)

    }
Janice Zhan
  • 571
  • 1
  • 5
  • 18
  • If you want to present in full screen then don't set `modalPresentationStyle`, normally present `editVideoViewController` and it will displayed in full screen – Ketan Parmar Jul 26 '16 at 05:42
  • I have tried presentViewController without modal style, but it gave me an error that UIVideoEditorController has to be presented by popover – Janice Zhan Jul 26 '16 at 05:54
  • then i think you must present it as popover!! – Ketan Parmar Jul 26 '16 at 06:10
  • I try to set preferredContentSize editVideoViewController.preferredContentSize = CGSizeMake(700, 768), it only change the popover view height. I do not know why there is no change on its width. – Janice Zhan Jul 26 '16 at 06:17

1 Answers1

3

There is no way to show UIVideoEditorController full screen. You can put it inside some container controller. And then configure this container controller preferredContentSize with screen bounds. You will get almost full-screen size popover.

let containerVC = UIViewController()
containerVC.preferredContentSize = UIScreen.main.bounds.size
containerVC.modalPresentationStyle = .popover
let ppc = containerVC.popoverPresentationController
ppc?.delegate = self
ppc?.sourceView = containerVC.view
ppc?.sourceRect = UIScreen.main.bounds
ppc?.permittedArrowDirections = .init(rawValue: 0 )
ppc?.canOverlapSourceViewRect = true

let videoController = UIVideoEditorController()

containerVC.addChild(videoController)
containerVC.view.addSubview(videoController.view)
videoController.didMove(toParent: containerVC)

self.present(containerVC, animated: true)
A Jar of Clay
  • 5,622
  • 6
  • 25
  • 39
Andrew
  • 61
  • 3
  • The "Cancel" button inside UIVideoEditorController doesn't trigger a `videoEditorControllerDidCancel` with this solution. However, videoEditorController:didSaveEditedVideoToPath is called when the "Use" button is tapped, meaning the delegate is set correctly. Not sure why the popover is interfering with the left bar button. – Josh Gafni Aug 13 '23 at 02:12