私のアプリはランドスケープのみをサポートしています。ビュー コントローラーのビューに MPMoviePlayerController を追加しました。
全画面ボタンを押すと、正常に動作し、iOS 5 より前の iOS バージョンでのみ横向きに回転します。ただし、iOS 5.0 以降では、縦向きもサポートされます (全画面モードに入った場合のみ)。
iOS 5.0 以降でポートレート サポートを無効にするにはどうすればよいですか?
私のアプリはランドスケープのみをサポートしています。ビュー コントローラーのビューに MPMoviePlayerController を追加しました。
全画面ボタンを押すと、正常に動作し、iOS 5 より前の iOS バージョンでのみ横向きに回転します。ただし、iOS 5.0 以降では、縦向きもサポートされます (全画面モードに入った場合のみ)。
iOS 5.0 以降でポートレート サポートを無効にするにはどうすればよいですか?
この問題を次のように解決しました: 2 つの方向をサポートするカスタム ナビゲーション コントローラーを作成します: UIInterfaceOrientationLandscapeLeft && UIInterfaceOrientationLandscapeRight
詳細: 1. カスタム ナビゲーション コントローラーを作成する
CustomNavigationController.h ファイル
#import <UIKit/UIKit.h>
@interface CustomNavigationController : UINavigationController
-(CustomNavigationController*)initWithRootViewController:(UIViewController *)rootViewController;
@end
CustomNavigationController.m ファイル
@implementation IORNavigationController
-(CustomNavigationController*)initWithRootViewController:(UIViewController *)rootViewController
{
self = [super initWithRootViewController:rootViewController];
if (self)
{
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
2. Appdelegate で、セルフ ナビゲーション コントローラーを追加します。
Appdelegate.h
@property (nonatomic, retain) CustomNavigationController* navigationController;
Appdelegate.m
self.navigationController = [[[CustomNavigationController alloc] initWithRootViewController:start] autorelease];
self.navigationController.view.autoresizesSubviews = YES;
window.rootViewController = self.navigationController;
[self.navigationController setNavigationBarHidden:YES];
これで、横向きの 2 つの向きとビデオを備えたアプリができました。
MPMoviePlayerViewController をサブクラス化し、shouldAutorotatoToInterfaceOrientation メソッドをオーバーライドして、ランドスケープ モードのみをサポートしてみてください。
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
if((toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight))
{
return true;
}
else
{
return false;
}
}