0

私のアプリはランドスケープのみをサポートしています。ビュー コントローラーのビューに MPMoviePlayerController を追加しました。

全画面ボタンを押すと、正常に動作し、iOS 5 より前の iOS バージョンでのみ横向きに回転します。ただし、iOS 5.0 以降では、縦向きもサポートされます (全画面モードに入った場合のみ)。

iOS 5.0 以降でポートレート サポートを無効にするにはどうすればよいですか?

4

2 に答える 2

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 つの向きとビデオを備えたアプリができました。

于 2013-06-10T13:10:45.483 に答える
0

MPMoviePlayerViewController をサブクラス化し、shouldAutorotatoToInterfaceOrientation メソッドをオーバーライドして、ランドスケープ モードのみをサポートしてみてください。

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    if((toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight))
    {
        return true;
    }
    else
    {
        return false;
    }    
}
于 2012-05-19T02:56:57.733 に答える