我想禁用UIImagePickerView的自动旋转。所以我使用了下面的代码:禁用UIImagePickerController的自动旋转
UIDevice *currentDevice = [UIDevice currentDevice];
[parentViewController presentViewController:imagePicker animated:YES completion:nil];
while ([currentDevice isGeneratingDeviceOrientationNotifications])
[currentDevice endGeneratingDeviceOrientationNotifications];
它禁用ImagePickerView,但它也禁用了旋转根视图。但我想在我的根视图控制器中的自动旋转功能(或者我只想在我的ImagePickerController中禁用自动旋转功能)。为了澄清,在禁用UIImagePickerController自动旋转之前,自动旋转在我的根视图中处于活动状态。
最新通报&答::
我找到了答案。写下面的代码启用自动旋转:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
如果您有任何图像处理(其实我有),调用此方法完成所有图像处理任务之后。在我的情况下,我在图像处理之前调用它,并且它没有启用方向。