0

私のアプリはナビゲーションコントローラーを使用しており、ランドスケープサポートを挿入しようとしています! 次のコードで IBAction (UIButton に接続) で呼び出される NavigationController とビューがあります。

view *myview = [[view alloc] initWithNibName:@"view" bundle:[NSBundle mainBundle]];
[self pushViewController:myview animated:YES];

もちろん、NavigationController_Class に「myview.h」をインポートしました

したがって、ランドスケープのために、このコードを「myview.m」と「NavigationController_Class.m」に挿入しました

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

どうしたの?動作しますが、スタックからビューをポップするボタンをタッチすると、これは右から左ではなく、上から下にスクロールします!

何が問題になるか知っていますか?ありがとう!

4

1 に答える 1

3

UINavigationController中にあると思いUITabBarControllerますか?

解決策は、ナビゲーションスタック内の各View ControllerのメソッドをオーバーライドしshouldAutorotateToInterfaceOrientation:(最後のメソッドは必要ありません)、YESサポートされているオリエンテーションに戻ることです。

于 2011-03-02T20:35:38.370 に答える