0

iPad アプリで写真を撮ろうとしていますが、UIImagePickerController を起動すると、カメラが間違った向きで画像を表示します。

UIImagePickerController を呼び出したコードは次のとおりです。

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0 || buttonIndex == 1) {
        // Initialization
        self.imgPicker = [[UIImagePickerController alloc] init];
        self.imgPicker.allowsEditing = YES;
        self.imgPicker.delegate = self;

        // Chosing the source
        if (buttonIndex == 0) {
            self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; // Displayed in the good orientation
        }
        else {
            self.imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
            self.imgPicker.showsCameraControls = YES;
        }

        // Popup pour la photo
        self.imgPicker.allowsEditing = YES;
        self.imgPicker.contentSizeForViewInPopover = CGSizeMake(1000, 700);
        self.photoPopOver.delegate = self;
        self.photoPopOver = [[UIPopoverController alloc] initWithContentViewController:self.imgPicker];
        [self.photoPopOver presentPopoverFromRect:self.photoBut.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
    else {
        [self cancel];
    }
}

知っておくべきこと: - に設定するsourceTypeUIImagePickerControllerSourceTypePhotoLibrary、ビューが正しく表示されます - 写真を撮ると、適切な回転で表示されます

それを伝えるのが役立つかどうかはわかりませんが、親ビューコントローラーには次のものがあります:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

どうすれば修正できますか?どうもありがとう !

4

2 に答える 2

2

//カメラUIImageを使用して選択した方向を修正するソリューションがここにあります。UIImagePickerViewController

向きの問題を修正する例を次に示します。ここで確認してください。

IOS の向きの問題を修正するために、カテゴリが定義されています。iOSデバイスの「カメラ」アプリを使用してポートレートモードで写真を撮り、カメラのUIImagePickerViewControllerデフォルトの向きがLandscape

于 2013-10-14T08:14:58.693 に答える