UIImagePickerController camera view rotating strangely on iOS 8 (pictures)

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

    This is the code I used to fix my app that was rotating the openCV camera into landscape if the camera was started with the device on the desk in Face Up position. The camera needed to be forced into portrait mode for the app to function correctly.

    - (BOOL)shouldAutorotate
     {
        [super shouldAutorotate];
        return NO;
     }
    
    -(void)viewDidAppear:(BOOL)animated
    {
    
        [super viewDidAppear: animated];
    
        if([[UIDevice currentDevice]orientation] == UIDeviceOrientationFaceUp)
            {
                if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft)
                {
                    [[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
                }
                else
                {
                    [[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
                }
            }
    }
    

提交回复
热议问题