带有cameraOverlayView的UIImagePickerController - 错误放置的视图

时间:2015-09-11 07:05:05

标签: ios autolayout

我有UIImagePickerController个自定义cameraOverlayView。

我像这样创建imagePicker:

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:^{

}];

出于某种原因,OverlayViewController的视图放错了位置。似乎没有计算约束。但是,如果我在完成块中显式调用[self.overlay viewWillAppear:NO];,它们的布局似乎可以正确呈现。

经过一些调查后,似乎没有为viewWillAppear调用viewDidAppearOverlayViewController

但是,如果我从模态“自定义图库视图控制器”返回到imagePicker,则会调用这些方法。

即: rootVC-> (没有电话) - > imagePicker - > customGalleryVc customGalleryVc(dismiss modal) - > (呼吁willAppear) - > imagePicker

这是什么?我是否遗漏了视图层次结构的基本原理?

谢谢!

0 个答案:

没有答案