画面を回転した際に、表示内容が回転するかどうかの設定。
UIViewController クラスの shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation を書き換えれば(オーバーライドすれば)よい。
デフォルトでは以下のようになっていて、上下逆さま(UIInterfaceOrientationPortraitUpsideDown)以外の3つの向きに対応している。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
次のように書き換えれば、通常の向き(ホームボタンが下)で固定される。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
interfaceOrientationは以下の4つの値を取る。
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationPortraitUpsideDown
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight