Reputation: 7536
I have extended the UIImagePickerController, but I am not sure the how to have my custom overlay displayed. The one presented in the storyboard appears to be ignored and the adding it as a separate view doesn't seem to help either. I am wondering whether I am doing this in the right part of the lifecycle or whether there is an additional attribute I need to set?
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;
}
}
}
Other examples, which do work, have the UIImagePickerController created from another UIView, but I would rather avoid an otherwise empty UIView for simply creating the UIImagePickerController.
Using Swift 2
Upvotes: 0
Views: 3146
Reputation: 15331
Per the 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.
You are attempting to subclass UIImagePickerController. You should create a view with the custom UI you want for video capture then set the instance of UIImagePickerController instance's overlayView. That view can have subview's that are controls that target the UIImagePickerController's presentingViewController.
Upvotes: 1