How do you tell whether UIImagePickerController ca

2019-08-02 19:37发布

IOS 6 on the Ipad rotates the UIImagePickerController cameraOverlayView on landscape mode, but IOS 6 on the iphone 3GS does not - thank you Apple!

I dont know the behaviour for IOS 5, or other devices, so is there a way of predicting this behaviour so i can apply a rotation transform on the overlay view?

thanks

1条回答
The star\"
2楼-- · 2019-08-02 19:53

I had this issue as well. Here's what I discovered:

In the Target's "iPad Deployment Info" config, make sure you've enabled "Landscape Left" and "Landscape Right" modes - even if your app doesn't really support these (this can be done through the info.plist file as well, obviously).

enter image description here

Next, in your UIViewController(s), force them to Portrait:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}

Now the UIImagePickerController should rotate correctly when the iPad is rotated to landscape - but your UIViewController will still be Portrait-only.

查看更多
登录 后发表回答