I am trying to use a CameraOverLayView
with a UIImagePickerController
using Storyboards in XCode.
In the storyboard, CameraViewController
Segues to ImagePickerController
, which has a CameraOverlayView
in it.
In my CameraViewController
implementation file, I have this code:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
UIImagePickerController *controller = [segue destinationViewController];
controller.sourceType = UIImagePickerControllerSourceTypeCamera;
controller.delegate = self;
//Here's where I need to assign the CameraOverlayView
//the view defined in my Storyboard
}
Programmatically, I can create a new CameraOverlayView
instance and assign it to controller.cameraOverlayView
, but is it possible to use the view created in the storyboard as part of the ImagePickerController
Scene, and if so, how?
Unfortunately, UIImagePickerController
does not have an outlet for cameraOverlayView
. Your best bet is to create your own outlet referencing the view that you want to use as an overlay and assign it to the destinationViewController
in prepareForSegue:
.
Alternatively, you can embed the UIImagePickerController
in a container view and just put your overlay view on top of the container view manually. The effect will be the same and you get more control over the behaviour.
Did you try?
[self.storyboard instantiateViewControllerWithIdentifier:@"YourOverlayView"];
And then assign it to the UIImagePickerController instance ?
I think this way you can still enjoy the benefits of editing with storyboard.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.