XcodeのTARGETS->GeneralでDeployment Info->Device Orientation(info.plistのSupported interface orientations)でサポートする向きを設定しておいて、
ViewControllerに以下の処理を入れる。
// 回転するかどうか
- (BOOL)shouldAutorotate
{
// 回転したときのViewの配置等の処理を記述
// 回転する場合YES, しない場合NO
return YES;
}
// サポートするインターフェースの向き
- (NSUInteger)supportedInterfaceOrientations
{
// UIInterfaceOrientationMaskPortrait : 縦(ホームボタン下)
// UIInterfaceOrientationMaskLandscapeLeft : 横(ホームボタン左)
// UIInterfaceOrientationMaskLandscapeRight : 横(ホームボタン右)
// UIInterfaceOrientationMaskPortraitUpsideDown : 縦(ホームボタン上)
// UIInterfaceOrientationMaskLandscape : 横(両方)
// UIInterfaceOrientationMaskAll : 4つ全て
// UIInterfaceOrientationMaskAllButUpsideDown : 縦(ホームボタン上)以外の3つ
return UIInterfaceOrientationMaskLandscape;
}
// インターフェースの向き(初期状態)
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
NSLog(@"preferredInterfaceOrientationForPresentation");
// UIInterfaceOrientationPortrait : 縦(ホームボタン下)
// UIInterfaceOrientationPortraitUpsideDown : 縦(ホームボタン上)
// UIInterfaceOrientationLandscapeLeft : 横(ホームボタン左)
// UIInterfaceOrientationLandscapeRight : 横(ホームボタン右)
return UIInterfaceOrientationLandscapeRight;
}
0 件のコメント:
コメントを投稿