0
votes

I have a modal view of style UIModalPresentationFormSheet, which presents a UIImagePickerControllerSourceTypeCamera. The form sheet modal view is presented from a custom view controller container

The image picker forces the app to change to portrait orientation. If the app is rotated to portrait mode before the image picker is dismissed then everything works fine.

However, after the image picker is dismissed whilst the device is in landscape the formsheet style modal view is now positioned off to the top left of its parent frame (see image).

orientation changes

I would guess that the modal view's superview is not rotating in the background. However, once the image picker is dismissed the modal view's frame is set as if it was.

1

1 Answers

0
votes
Create a custom class of UIImagePickerController. Override supportedInterfaceOrientations meted
- (NSUInteger) supportedInterfaceOrientations
{
    //Because your app is only landscape, your view controller for the view in your
    // popover needs to support only landscape
    return UIInterfaceOrientationMaskAll;
}
-(BOOL)shouldAutorotate{
    return yes;
}

//call custom view like this
   CustomImagePickerViewController *picker = [[CustomImagePickerViewController alloc] init];
        picker.supportedInterfaceOrientations= UIInterfaceOrientationMaskAll;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        picker.delegate = self;
        [self presentViewController:picker animated:YES completion:nil];