カスタムiPhoneアプリで垂直ビューから水平ビューに回転する方法

StackOverflow https://stackoverflow.com/questions/974905

  •  13-09-2019
  •  | 
  •  

質問

1つのグラフビューとその中にセグメント化されたコントロールを含む1つのビューコントローラーセットがあります。ビューを水平に回転させるにはどうすればよいですか?また、別のビューを水平方向にロードすることは可能ですか?

事前にt​​hx、mladen

役に立ちましたか?

解決

オリエンテーションのサポートは、次の方法で実装します。

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
// Just delete the lines for the orientations you don't want to support
  if((toInterfaceOrientation == UIInterfaceOrientationPortrait) ||
     (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) ||
     (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)) ||
     (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight))  {   
   return YES; 
   }
return NO;
}

次に、回転時に新しい ViewController をロードするには、次のようにします。

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
  if((fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
     (fromInterfaceOrientation == UIInterfaceOrientationLandscapeRight))
  {    
    // Load the view controller you want to display in portrait mode...
  }
}

iPod アプリで CoverFlow モードに移行するときに見られるように、スムーズな移行を実行したい場合は、新しいビューの alpha プロパティを操作するアニメーションを設定することもできます。

免責事項インターフェイスの回転をサポートする推奨方法は 3.0 で変更されます。上記の方法は引き続き機能しますが、よりスムーズなアニメーションを取得する方法があります。しかし、私たちはそれについてここで話すべきではありません。もっと。週。

別の免責事項インターフェイスの回転をサポートする推奨方法は 6.0 で再び変更されます。上記の方法は引き続き機能しますが、よりスムーズなアニメーションを取得する方法があります。

他のヒント

デバイスを回転するには、このメソッドを viewController に実装する必要があります。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top