デバイスが横向きに回転したときに、カバーフロー スタイルのビューを横向きに表示する必要があるアプリに取り組んでいます。以前にいくつかのアプリに取り組んできましたが、横向き/回転を必要とするアプリはなかったので、経験がありません。カバーフロー ビューを描画するコードはありますが、表示するのは大変です。
私が望むのは、iPod アプリがカバーフローを表示するときの基本的な動作と同じです。下のビューは回転しませんが、カバーフローは上でフェードインし、回転して縦向きに戻すとフェードアウトします。
shouldAutorotateToInterfaceOrientation とモーダル ビューがフェード トランジションで表示されるか、ここにあるテクニックを使用することと関係があると思います。
私の主な問題は、モーダル ビューが表示されているが、コンテンツが横向きに回転していないことだと思います。私は何をすべきか?
これが私が今使っているコードです:
親ビュー
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
NSLog(@"rotating?");
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
return YES;
}
if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)) {
NSLog(@"rotating");
CoverFlowViewController *coverFlowView = [[CoverFlowViewController alloc] init];
[coverFlowView setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:coverFlowView animated:YES];
[coverFlowView release];
}
return YES;
}
モーダルビュー
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
NSLog(@"rotating? going back?");
if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)) {
return YES;
} else {
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
return NO;
}