1

UIImagePickerView の自動回転を無効にしたい。そこで、次のコードを使用しました。

UIDevice *currentDevice = [UIDevice currentDevice];


        [parentViewController presentViewController:imagePicker animated:YES completion:nil];

        while ([currentDevice isGeneratingDeviceOrientationNotifications])
            [currentDevice endGeneratingDeviceOrientationNotifications];

ImagePickerView を無効にしますが、ルート ビューの回転も無効にします。しかし、ルート ビュー コントローラーで自動回転機能が必要です (または、ImagePickerController でのみ自動回転を無効にしたい)。明確にするために、UIImagePickerController の自動回転を無効にする前に、ルート ビューで自動回転がアクティブでした。

更新と回答::

私は答えを見つけました。自動回転を有効にするには、次のコードを記述します。

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

画像処理がある場合 (実際に行ったことがあります)、すべての画像処理タスクが完了した後にこのメソッドを呼び出します。私の場合、画像処理の前に呼び出しましたが、向きが有効になりませんでした。

4

2 に答える 2

-1

これを試して :

@interface UIImagePickerController(addition)

@end
@implementation UIImagePickerController(addition)

-(BOOL)shouldAutorotate{
    return NO;
}

@end
于 2015-06-22T14:46:56.027 に答える