2

このフォーラム(および他のフォーラム)を検索しましたが、まだ解決策が見つかりません。ランドスケープモードのアプリがあります。すべて問題ありませんが、別のビュー(UITableを使用)に変更すると、ポートレートモードになり、回転しません。私は一日中試しましたが、それを理解することはできません。

@property (nonatomic, strong) IBOutlet UIView *aView;
@property (nonatomic, strong) IBOutlet UIViewController *aViewcontroller;
-----
aViewcontroller = [[UIViewController alloc] initWithNibName:@"ViewController" bundle:nil];
aViewcontroller.view = aView;
-----
[self presentModalViewController:aViewcontroller animated:YES];
//got my view in portrait orientation.

.xibファイルのビューはすべてOrientation:Landscapeに設定されています。これは簡単なはずですよね?

よろしくお願いします!

4

1 に答える 1

2

デフォルトでは、UIViewControllerは縦向きのみをサポートします。他の方向をサポートするには、必要な方向をサポートする新しいカスタムビューコントローラーを作成する必要があります。

手順:

新しいカスタムビューコントローラを作成するViewControllerLandscape

次に、それをmainnViewControllerにインポートします

#import "ViewControllerLandscape.h"

コードを変更します。

aViewcontroller = [[ViewControllerLandscape alloc] initWithNibName:@"ViewController" bundle:nil];
aViewcontroller.view = aView;
[self presentModalViewController:aViewcontroller animated:YES];

ViewControllerLandscapeメソッドを追加します。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
      (interfaceOrientation == UIInterfaceOrientationLandscapeRight))  {   
       return YES;
    }
    return NO;
}
于 2012-07-26T13:43:10.397 に答える