0

ボタンをクリックすると、1つのクラスコントローラービューをサブビューとして表示する必要があるアプリケーションを開発しています。ビューコントローラーをサブビューとして追加しましたが、正常に動作します。

TempViewControlleriPad *tempScreen=[[TempViewControlleriPad alloc]initWithNibName:@"TempViewControlleriPad" bundle:nil];
[self.view addSubview:tempScreen.view];
[tempScreen viewWillAppear:NO];

デバイスの向きを回転すると、サブ ビューがその向きに反応しませんでした。これは、サブ ビューが回転しなかったことを意味します。

TempViewControlleriPad orientation method:-


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
             [[NSBundle mainBundle] loadNibNamed:@"TempViewControlleriPad" owner:self options:nil];
    }
    else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
         [[NSBundle mainBundle] loadNibNamed:@"TempViewControlleriPadLandscape" owner:self options:nil];
    }

    return YES;

}

この向きの問題を解決するにはどうすればよいか教えてください。

前もって感謝します。

4

1 に答える 1

1

サブビューのコントローラーは UIViewController ですか? ビューコントローラーを別のコントローラーに埋め込むことは想定されていません。アップルのドキュメントから:

同じビュー階層の異なる部分を管理するために、複数のカスタム ビュー コントローラーを使用しないでください。同様に、単一のカスタム ビュー コントローラー オブジェクトを使用して、複数の画面に相当するコンテンツを管理しないでください。 http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/AboutViewControllers/AboutViewControllers.html#//apple_ref/doc/uid/TP40007457-CH112-SW12

サブビューに自動サイズ変更マスクを設定できます。

于 2011-10-07T06:44:52.897 に答える