旋转设备时如何显示横向遮盖流样式视图?

时间:2011-01-10 06:04:23

标签: iphone orientation landscape modalviewcontroller coverflow

我正在开发一款应用,当设备旋转到横向时,需要在横向显示封面流样式视图。我以前曾经在一些应用程序上工作,但是没有一个需要横向/旋转,所以我没有经验。我有代码来绘制封面流视图,但提出它是很困难的。

我想要的基本上就像iPod应用程序在显示封面时的功能。下面的视图不会旋转,但是封面流会在顶部淡入,并在旋转回到纵向时淡出。

我猜测它与shouldAutorotateToInterfaceOrientation有关,并且模式视图显示为淡入淡出过渡,或使用此处的技术:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/22285-replicating-cool-ipod-landscape-transition-iphone.html

我想我的主要问题是提供了模态视图,但它的内容没有旋转到横向。我该怎么办?

这是我现在使用的代码:

父母观点

- (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;

}

1 个答案:

答案 0 :(得分:1)

你应该在里面进行过渡:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

}