我试着解决这个问题已经有一段时间了,但一无所获。
我在iPad 2上使用摄像头-我的应用程序是横向的,但我想在纵向模式下使用摄像头。我似乎不能强迫ImagePicker a进入纵向模式,b停止自动旋转。
有没有办法强制ImagePicker进入纵向(或横向)模式,和/或停止它的自动旋转?
即使应用程序处于横向模式,并且设置为仅向横向方向返回YES,但当您旋转iPad 2时,ImagePicker会忽略这一点,并旋转为纵向。
如果我可以强迫它停留在风景中,那么(尽管不理想)我可以重新设计应用程序,以便在风景中使用相机,但我似乎甚至无法做到这一点!
非常感谢您的帮助!
发布于 2011-06-20 15:30:14
您需要重写的方法称为:
_isSupportedInterfaceOrientation:
所以它应该看起来像这样:
@interface PortraitImagePickerController : UIImagePickerController {
}
@end
@implementation PortraitImagePickerController
- (BOOL)_isSupportedInterfaceOrientation:(UIDeviceOrientation)orientation{
return UIDeviceOrientationIsPortrait(orientation);
}
@end但这绝对是私有方法,所以Apple可能会拒绝你的应用程序
发布于 2015-05-08 21:40:37
好吧,我已经找到了一种更方便的方法,并且没有使用私有代码的风险。
将UIImagePickerController子类化,并在其.m文件中添加以下方法。
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}https://stackoverflow.com/questions/6007483
复制相似问题