我有一個處於橫向模式的應用程序。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) ;在你的照片庫視圖中使用 –