I love iPhone, Android, Cocos2d-x
        [iPhone 開発メモ] 本体の回転を検知する
iPhone を横方向に回転させた時に検知する方法のメモです。
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)FromInterfaceOrientation {
	if(FromInterfaceOrientation == UIInterfaceOrientationPortrait){
		// 横向き
	} else {
		// 縦向き
	}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	return YES;
}
shouldAutorotateToInterfaceOrientation メソッドで YES を返すようにすると回転時に以下のメソッドが実行されます。いずれも UIViewController クラスのメソッドです。
- didRotateFromInterfaceOrientation
 - 回転後に実行される
 - willRotateToInterfaceOrientation
 - 回転開始時に実行される
 
関連する投稿
One comment
コメントをどうぞ
Additional comments powered by BackType
2bazaar…
…