2009-10-17 83 views
3

我有2个GUI和2个控制器 1称为景观控制器,第二个称为高控制器。旋转肖像景观2 XIB

现在一般我所说的highguicontroller,当我转动我的iPhone它检测到,然后显示landscapeguicontroller: 代码:

landscapeguicontroller *neu =[[landscapeguicontroller alloc] initWithNibName:nil bundle:nil]; 
    [self presentModalViewController:neu animated:YES];  
    [self dismissModalViewControllerAnimated:YES]; 

的问题是,那么动画从推新窗口超出了iPhone的一边,进入窗口。

在Landscapeguicontroller,我已经加入到了下面几行:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

时,我想回去highguicontroller我打电话:

[self dismissModalViewControllerAnimated:YES]; 

所有作品,只是在第二个动画我看到了正确的“旋转动画”。 你有什么建议吗?

那么短的问题描述:在 从高分到景观1.动画,景观被推到窗口 但在2动画从景观到高,旋转看起来像一个真正的旋转...

我想1.animation模样2.动画

问候 Ploetzeneder

回答

3

为了避免“问题是,那么动画会将新窗口从iphone的另一侧推入窗口。”,尝试设置视图控制器的modalTransitionStyle属性设置为下列之一,不管你喜欢: 的typedef枚举{ UIModalTransitionStyleCoverVertical = 0, UIModalTransitionStyleFlipHorizo​​ntal, UIModalTransitionStyleCrossDissolve, } UIModalTransitionStyle;

另外,如果你想避免动画旋转,你可以设置你的shouldRotate ...方法来禁止其他方向,但是当设备在物理上改变方向时设置接收通知,并在适当的方向上呈现你的模态视图控制器。代码示例。

通知反映设备的物理方向,无论接口是否允许更改,您都可以接收它们。 (您可以查看UIApplications的statusBarOrientation属性以查看UI所处的方向)。

1

这听起来像你想的顺序是这样的:

  1. 物理设备旋转从纵向到横向
  2. 动画的纵向视图(highguicontroller)为横向
  3. 推横向视图(landscapeguicontroller)至多从屏幕的新“底部”

如果这是正确的,则需要在highguicontroller实施中具有以下内容:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown; 
} 

这将处理第2步(它会将纵向视图旋转到任一方向的横向)。

然后你就会想是这样的:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
    if(fromInterfaceOrientation == UIInterfaceOrientationPortrait) { 
    [self presentModalViewController:landscapeguicontroller animated:YES]; 
    } 
    else { 
    [self dismissModalViewControllerAnimated:YES]; 
    } 
} 

这应该呈现横向视图旋转动画完成后,再关闭它的设备转回到遗像。

希望有帮助!