如何防止模态UIImagePickerController旋转?

con*_*are 9 iphone rotation uiviewcontroller uiimagepickercontroller ios

我有一个完全支持旋转的应用程序.我在模态上添加了一个UIImagePickerController没有支持的UIInterfaceOrientationLandscape,我无法让控制器留在肖像中.

换句话说,我需要禁用旋转,UIImagePickerController因此它保持纵向,而不删除我的应用程序的其余部分的旋转.这似乎是基本的,但我似乎找不到它.如何防止这种旋转?



UPDATE

正如所建议的那样,我尝试使用以下代码进行子类化:

@interface UAImagePickerController : UIImagePickerController {
}
@end

@implementation UAImagePickerController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return UIDeviceOrientationIsPortrait(toInterfaceOrientation);
}
@end
Run Code Online (Sandbox Code Playgroud)

这条线没有受到断点的打击......我认为必须有一些关于它的时髦 UIImagePickerView

Sha*_*rog -2

子类化UIImagePickerController并让新类实现shouldAutorotateToInterfaceOrientation:以使其仅旋转到纵向,如下所示:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Run Code Online (Sandbox Code Playgroud)