我有一个完全支持旋转的应用。我在模态上添加了UIImagePickerController
,但是对UIInterfaceOrientationLandscape
没有支持,我无法让控制器保持纵向。
换句话说,我需要禁用UIImagePickerController
的旋转,使其保持纵向,而不会移除我应用的其余部分的旋转。这似乎是基本的,但我似乎找不到它。如何防止这种旋转?
的更新
正如所建议的那样,我尝试使用以下代码进行子类化:
@interface UAImagePickerController : UIImagePickerController {
}
@end
@implementation UAImagePickerController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIDeviceOrientationIsPortrait(toInterfaceOrientation);
}
@end
这条线没有受到断点的打击......我认为UIImagePickerView
答案 0 :(得分:-1)
我在UIViewController中创建了我的UIImagePickerController,并实现了相应的shouldAutorotateToInterfaceOrientation方法并将其呈现为
[self.view addSubview:myImagePicker.view];
[targetVC.navigationController presentModalViewController:self animated:YES];
希望有所帮助。
答案 1 :(得分:-2)
子类UIImagePickerController
并让新类实现shouldAutorotateToInterfaceOrientation:
以使其仅旋转为纵向,如下所示:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
答案 2 :(得分:-4)
你应该覆盖_isSupportedInterfaceOrientation:而不是shouldAutorotateToInterfaceOrientation:
iPad 2 UIImagePickerController camera auto-rotation driving me mad!
答案 3 :(得分:-4)
将其放在ViewControllers @implementation块上方(在.m文件中)
@implementation UIImagePickerController (portrait)
- (BOOL)_isSupportedInterfaceOrientation:(UIDeviceOrientation)orientation
{
return UIDeviceOrientationIsPortrait(orientation);
}
@end