3

我有 2 个 GUI 和 2 个控制器 1 个称为 Landscapeguicontroller,第二个称为 highguicontroller。

现在通常我调用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.animation

最好的问候 Ploetzeneder

4

2 回答 2

3

为避免“问题是动画将新窗口从 iphone 的外侧向上推到窗口中。”,请尝试将视图控制器的 modalTransitionStyle 属性设置为以下之一,无论您喜欢什么: typedef enum { UIModalTransitionStyleCoverVertical = 0, UIModalTransitionStyleFlipHorizo​​ntal, UIModalTransitionStyleCrossDissolve, } UIModalTransitionStyle;

此外,如果您想避免动画旋转,您可以设置您的 shouldRotate... 方法以禁止其他方向,然后设置为在设备物理更改方向时接收通知,并在适当的方向显示您的模态视图控制器它。有关此示例,请参阅 Apple 的“AlternateViews”示例代码。

通知反映了设备的物理方向,无论界面是否允许更改,您都可以收到通知。(您可以查看 UIApplications 的 statusBarOrientation 属性以了解 UI 的方向)。

于 2009-11-30T00:23:06.153 回答
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];
  }
}

这应该在旋转动画完成后呈现横向视图,然后在设备旋转回纵向后将其关闭。

希望有帮助!

于 2009-10-17T07:56:35.580 回答