vendredi 11 septembre 2015

UIImagePickerController with cameraOverlayView - misplaced views

I have a UIImagePickerController with a custom cameraOverlayView.

I create the imagePicker like this:

self.overlay = [self.storyboard instantiateViewControllerWithIdentifier:@"OverlayViewController"];
self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
self.picker.showsCameraControls = NO;

// Insert the overlay
self.picker.cameraOverlayView = self.overlay.view;
self.overlay.pickerReference = self.picker;

self.picker.edgesForExtendedLayout = UIRectEdgeAll;
self.picker.extendedLayoutIncludesOpaqueBars = YES;

self.picker.delegate = self.overlay;


[self presentViewController:self.picker animated:NO completion:^{

}];

For some reason, the OverlayViewController's view is misplaced. It seems as if the constraints haven't been calculated. However, if I explicitly call [self.overlay viewWillAppear:NO]; in the completion block, they layout seems to render correctly.

After some investigation it seems as if viewWillAppear and viewDidAppear is not called for the OverlayViewController.

However, these methods are called if I come back to the imagePicker from a modal 'custom gallery viewcontroller'.

I.e: rootVC-> (No calls) -> imagePicker -> customGalleryVc customGalleryVc (dismiss modal) -> (Calls to willAppear) -> imagePicker

What is this? Am I missing something with the fundamentals of the view-hierarchy?

Thank you!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire