向自定义 UIImagePickerController 添加覆盖?

Adding overlay to custom UIImagePickerController?

我已经扩展了 UIImagePickerController,但我不确定如何显示我的自定义覆盖。情节提要中显示的那个似乎被忽略了,将其添加为单独的视图似乎也无济于事。我想知道我是否在生命周期的正确部分执行此操作,或者是否需要设置其他属性?

class VideoRecorderViewController: UIImagePickerController {
    var overlayView : UIView?

    override func viewDidLoad() {
        super.viewDidLoad()

        self.mediaTypes = [kUTTypeMovie as String]
        self.sourceType = .Camera
        self.cameraCaptureMode = .Video

        self.allowsEditing = false
        self.delegate = delegate
        self.showsCameraControls = false
        self.overlayView = (NSBundle.mainBundle().loadNibNamed("RecorderOverlayView", owner: self, options: nil)[0] as! UIView)

        if (self.overlayView != nil) {

            self.overlayView?.frame = self.cameraOverlayView!.frame
            self.cameraOverlayView = self.overlayView;            
        } 
    }    
}

其他确实有效的示例从另一个 UIView 创建了 UIImagePickerController,但我宁愿避免使用其他空的 UIView 来简单地创建 UIImagePickerController。

使用 Swift 2

根据 UIImagePickerController Class Reference:

IMPORTANT

The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.

您正在尝试继承 UIImagePickerController。您应该创建一个带有您想要用于视频捕获的自定义 UI 的视图,然后设置 UIImagePickerController 实例的 overlayView 的实例。该视图可以包含子视图,这些子视图是针对 UIImagePickerController 的 presentingViewController 的控件。