あなたの質問は非常に漠然としていました。これは一般的な説明です。以下のメソッドをオーバーライドして、向きの変更を処理できます
以下のメソッドをオーバーライドする
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// return YES to supported orientation.
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
/* Subclasses may override this method to perform additional actions immediately
prior to the rotation. For example, you might use this method to disable view
interactions, stop media playback, or temporarily turn off expensive drawing or live
updates. You might also use it to swap the current view for one that reflects the new
interface orientation. When this method is called, the interfaceOrientation property
still contains the view’s original orientation.
*/
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
/*Subclasses may override this method to perform additional actions immediately after
the rotation. For example, you might use this method to reenable view interactions,
start media playback again, or turn on expensive drawing or live updates. By the time
this method is called, the interfaceOrientation property is already set to the new
orientation.*/
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
/*This method is called from within the animation block used to rotate the view.
You can override this method and use it to configure additional animations that should
occur during the view rotation. For example, you could use it to adjust the zoom level
of your content, change the scroller position, or modify other animatable properties
of your view.*/
}
このようにviewDidLoadまたはviewDidAppearでデバイスの向きを確認しないでください
if( [UIDevice currentDevice].orientation == UIInterfaceOrientationLandscapeLeft)
OR if(UIInterfaceOrientationIsLandscape([UIDevice currentDevice].orientation))
多くの場合、iPhone/iPad をテーブルの上に置いた場合など、予期しない結果が生じるためです (私はこれを経験しました... 非常に厄介な問題です)。
この アップル開発者リンクは、向きの処理に関する詳細情報を提供します