Reputation: 65
My iPad application is in Landscape. From ViewController1 I presented ViewController2. From there when camera is opened with UIImagePicker (while keeping the device in portrait mode), ViewController2 moves down a little bit and we can see ViewController1 got rotated to portrait.
Code:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
if (hasCamera){
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.showsCameraControls = NO;
UIView *overlayView = [SCFUtility cameraOverlayViewForBounds:imagePicker.view.bounds withShapeRect:CGSizeMake(400, 560) target:self];
imagePicker.cameraOverlayView = overlayView;
[overlayView addSubview:self.cameraTimerLabel];
}
else
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if (imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
if( [UIImagePickerController isCameraDeviceAvailable: UIImagePickerControllerCameraDeviceFront ])
{
imagePicker.cameraDevice=UIImagePickerControllerCameraDeviceFront;
}
[self.cameraTimerLabel setText:@"9"];
self.cameraCountDownTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(cameraCountDownTimerTriggered:) userInfo:nil repeats:YES];
}
else{
imagePicker.modalPresentationStyle = UIModalPresentationPopover;
imagePicker.popoverPresentationController.sourceView = self.addPhotoContainerView;
imagePicker.popoverPresentationController.sourceRect = self.addPhotoContainerView.bounds;
}
[self presentViewController:imagePicker animated:YES completion:nil];
self.imagePickerController = imagePicker;
Upvotes: 1
Views: 54
Reputation: 877
I would suggest you put a breakpoint in following callback methods (ViewController2 and ViewController1) for size change and trait collection change:
viewWillTransitionToSize:withTransitionCoordinator:
traitCollectionDidChange
And find out what is triggering rotation or view size changes.
Upvotes: 1