0

はい、この質問が何度も寄せられていることは知っていますが、これ以上役立つものは見つかりません。

3 つのビュー コントローラーを備えたナビゲーション コントローラーを使用して、前の画面のデータを保持する必要があるため、セグエは使用しませんが、次のようにします。

// When button is pressed
- (IBAction)changeView:(id)sender {
NSLog(@"Skipped connection screen");
ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondView"];

[self.navigationController pushViewController:vc animated:YES];

ここで、SecondView は、表示されるビュー コントローラーの識別子です。回転を右に水平にしたいだけなので、ビュー用に持っているすべての .m ファイルの先頭に次のコード スニペットを追加します。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{

return (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight);  
}

私の project-Info.plist に追加Initial interface orientation = Landscape (right home buttonし、プロジェクト設定にこの方向のみのサポートを追加しました。

問題は、iPhone で実行しているときに、携帯電話をどちらかの方向に向けると、向きが横向きから変わることです。元に戻そうとすると、うまくいきません。このアプリケーションが横向きに回転しないようにしたいと思います。

助言がありますか?事前にどうもありがとうございました。

4

2 に答える 2

2

以下のキーを .plist ファイルに追加すると、修正されると思います。

"Supported interface orientations" このキーの値は、"Landscape (right home button)"または任意の値になるため、アプリケーションは指定された向きのみをサポートします。

また、このコードをすべてのビュー コントローラーに追加します。

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation{
return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);  
}
于 2012-06-21T08:22:30.623 に答える
1

「リターン」コードで引数を使用する必要があります。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
   return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);  
}
于 2012-06-21T08:19:58.690 に答える