0

そのため、インターフェイスの向きが横向きに変わったときにモーダルに表示するビューがあります。ただし、向きが縦向きに戻り、モーダル ビューが閉じると、最初のビューのテーブルビューは横向きのままになります (このテーブル ビューは縦向きのみにする必要があります)。

コードは次のとおりです。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return ((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight) );
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if ((toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)) {
        [self performSegueWithIdentifier:@"showCatChart" sender:self];
    }
    if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
        [self refreshTableView];
    }
}

テーブルビューを更新しようとしましたが、再び縦向きにはなりません...これはビュー階層からのものである可能性があります... NavigationController->tableView(縦向きのみ)->tableview->landscapeViewModalController

4

2 に答える 2

0

appdelegate で以下を使用します。

[self.window addsubview:viewcontroller];

これだけでオリエンテーションの問題は解決します。

于 2012-11-13T17:56:50.963 に答える
0

iOS 6 では、以下を実装する必要があります。

- (BOOL)shouldAutoRotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

AppDelegate で、以下を変更する必要があります。

[self.window addSubview:viewController.view];

[self.window setRootViewController:viewController];

また、以前のバージョンの iOS をサポートする場合は、現在のコードを保持してください。

于 2012-11-14T13:39:20.997 に答える