2

消費者向けのほとんどの Android および iPhone フィットネス アプリには 2 つのインターフェイス モードがあることに気付きました。ポートレート モードでは、ユーザーはより詳細な情報を取得できますが、ユーザーがデバイスをランドスケープ モードにすると、全画面グラフが追加されて全体がカバーされます。画面。

iPhone でのデバイスの回転に応じて、別のビュー コントローラーへの遷移を実装する方法に興味があります。私の最初の考えは、傍受することです(willRotateToInterfaceOrientationイベント、次にアプリデリゲートを取得し、フルスクリーングラフビューコントローラーをウィンドウに追加します)。

iPhone の回転を別のビュー コントローラへの遷移に変えるより良い方法はありますか? ステータスバーを非表示にして、モーダルビューコントローラーをアニメーション付きのランドスケープモードでプッシュするのが好きですか?

4

3 に答える 3

1

このwillRotateToInterfaceOrientation方法はうまく機能します。

ビューの切り替えに加えて、他に次の 2 つの便利な操作を行うことができます。

1) ステータスバーを非表示/表示します。(私は風景に隠すのが好きです)

[[UIApplication sharedApplication] setStatusBarHidden:UIInterfaceOrientationIsLandscape(toInterfaceOrientation)  withAnimation:UIStatusBarAnimationSlide];

2) UINavigationBar を非表示/表示します。(たぶん、あなたの風景ビューは余分な高さの恩恵を受けるでしょう)

[self.navigationController setNavigationBarHidden:UIInterfaceOrientationIsLandscape(toInterfaceOrientation) animated:YES];
于 2013-05-22T13:59:42.363 に答える
0

willRotateToInterfaceOrientation メソッドを持つビュー コントローラーを 1 つ持つことができ、そのビュー コントローラーには他の 2 つのビュー コントローラーを変数として持つことができます。

デバイスが回転したら、viewcontrollers のビューを切り替えます (非常に大雑把なコード例:)

-(void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration {

if ((orientation == UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight)) {
    [self.secondViewController.view removeFromSuperView];
    self.firstViewController.view.frame = self.bounds;
    [self.view addSubView:self.firstViewController.view];
  } else {
    [self.firstViewController.view removeFromSuperView];
    self.secondViewController.view.frame = self.bounds;
    [self.view addSubView:self.secondViewController.view];
  }
}
于 2013-05-22T13:41:57.337 に答える