我有一个处于横向模式的应用程序。iPhone/iPad中的方向问题
该应用程序专为iPhone和iPad设计。
我正在打开照片库,从那里访问照片,并从我的一些视图中捕捉照片。
但据我所知,照片库只能在肖像模式下打开,所以我从下面显示的设置中选择所有的方向。
我也做了同样的事情iPad也。
所以我尝试从所有视图的代码。
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight ;
}
因此,所有的视图只能在肖像模式下锁定。
但我的看法仍然显示在肖像模式也。
对于图片库,我做了一个不同的类,如下所示。
@interface NonRotatingUIImagePickerController8 : UIImagePickerController
@end
@implementation NonRotatingUIImagePickerController
- (BOOL)shouldAutorotate
{
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait ;
}
@end
@interface NonRotatingUIImagePickerController2 : UIImagePickerController
@end
@implementation NonRotatingUIImagePickerController2
- (BOOL)shouldAutorotate
{
return NO;
}
@end
因此,我的照片库以纵向模式显示,但我的所有其他视图以纵向模式显示。
那么我该如何解决这个问题?
请帮帮我。
卡住了很长一段时间。
在此先感谢....
**Edited**
如果我做这样我的应用充分说明在风景模式,但是当我尝试打开照片库崩溃。
我该怎么做?
请帮忙....
所以我的照片库中显示POTRAIT模式但我的所有其他视图以POTRAIT模式显示。你什么意思?错字?如果可以的话,上传一个示例项目到Github并链接到这里,有人可以为你解决这个问题。 – Ricky
如果我没有从我的项目设置中选择肖像,如图中所示,那么我的应用程序将崩溃,因为照片库只能在iPhone的肖像模式下打开... – Manthan
self.view.transform = CGAffineTransformMakeRotation(M_PI_2) ;在你的照片库视图中使用 –