UIImagePickerController camera view rotating strangely on iOS 8 (pictures)

后端 未结 12 1458
我寻月下人不归
我寻月下人不归 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:22

    As @hitme said, it is a bug in iOS 8, but you can work around the issue by setting -[UIImagePickerController cameraViewTransform] before presenting it:

    CGFloat angle;
    switch (interfaceOrientation)
    {
        case UIInterfaceOrientationLandscapeLeft:
            angle = M_PI_2;
            break;
    
        case UIInterfaceOrientationLandscapeRight:
            angle = -M_PI_2;
            break;
    
        case UIInterfaceOrientationPortraitUpsideDown:
            angle = M_PI;
            break;
    
        default:
            angle = 0;
            break;
    }
    imagePicker.cameraViewTransform = CGAffineTransformMakeRotation([UIApplication sharedApplication].statusBarOrientation);
    

提交回复
热议问题