回転を検知する
iPadでは縦横の両方の使い方に対応していないとリジェクトされるらしい。
対応するためには、回転を検知してレイアウトを動的に修正したりしないといけない。
そんなときには、ViewControllerの中に
// Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { NSLog(@"should"); return YES; } -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)FromInterfaceOrientation { if(FromInterfaceOrientation == UIInterfaceOrientationPortrait || FromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){ // 横向き NSLog(@"よこ"); } else { // 縦向き NSLog(@"たて"); } }
これを書いておけば検知できる。
上のメソッドは、ViewBaseのプロジェクト作ればデフォルトで入っているはず。
下のメソッドで、縦横を検知している。
ポイントは、UIInterfaceOrientationPortraitとUIInterfaceOrientationPortraitUpsideDownで、上の条件だと縦方向から変化しましたよ、というのがわかる。