UIImagePickerController camera view rotating strangely on iOS 8 (pictures)

后端 未结 12 1452
我寻月下人不归
我寻月下人不归 2020-12-07 16:34

I have a very simple application: - All orientations are permitted with only a button on a screen - The button show a UIImagePickerController (to take a photo)

12条回答
  •  [愿得一人]
    2020-12-07 17:23

    I know it's an iOS bug, but i've implemented a temporary fix:

    on the view that presents the image picker, add this code if you don't get any orientation changes events (or use didRotateFromInterfaceOrientation otherwhise):

    - (void)viewDidLoad {
       [super viewDidLoad];
       // ....
    
       if ([[UIDevice currentDevice].systemVersion floatValue] >=8) {
           [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
       }
    
    }
    

    now on rotation simply dismiss and represent your imagepicker:

    - (void)didRotate:(NSNotification *)notification
    {
        if (self.presentedViewController && self.presentedViewController==self.imagePickerController) {
            [self dismissViewControllerAnimated:NO completion:^{
                [self presentViewController:self.imagePickerController animated:NO completion:nil];
            }];
        }
    }
    

    works a bit rough, but this is the best solution i've found

提交回复
热议问题