2011-09-17 129 views
0

什么是正确的方式来实现类似于iPhone的标准iPod应用程序中的效果 - 当设备旋转到横向模式时,视图改变为覆盖流程,但是过渡类型是淡入淡出而不是旋转屏幕?IOS旋转设备不旋转动画

这是怎么了加载模式的看法:

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { 
     carouselView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
     [self presentModalViewController:carouselView animated:YES]; 
    } 
} 

谢谢!

安德

回答

2

我后来发现它是更稳定的,以使用此解决方案:

在父视图控制器(在我的情况下,它是选项卡视图控制器)viewDidLoad方法补充一点:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:@"UIDeviceOrientationDidChangeNotification" object:nil]; 

,然后添加这个方法:

- (void) didRotate:(NSNotification *)notification {  

    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 
    if (UIInterfaceOrientationIsLandscape(orientation) && !self.modalViewController) { 
     [self presentModalViewController:carouselView animated:YES]; 
     [Globals sharedGlobals].startedAtLandscape = YES; 
    } 

    if (UIInterfaceOrientationIsPortrait(orientation) && self.modalViewController) { 
     [self dismissModalViewControllerAnimated:YES];  
     [Globals sharedGlobals].startedAtLandscape = NO; 
    } 
} 

最后,如果要防止旋转动画,请修改此方法,如下所示:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if(UIInterfaceOrientationIsLandscape(interfaceOrientation)) { 
     return NO; 
    } 
    return YES; 
} 
+0

presentModalViewController已被弃用。 –