Objective c 带2个XIB的旋转纵向景观

Objective c 带2个XIB的旋转纵向景观,objective-c,uiview,landscape,portrait,Objective C,Uiview,Landscape,Portrait,我有2个GUI和2个控制器 1称为LandscapeGUI控制器,第二个称为HighGUI控制器 现在,我通常调用HighGUI控制器,当我旋转iphone时,它会检测到,然后显示LandscapeGUI控制器: 代码: 问题是,然后动画将新窗口从iphone的另一侧推到窗口中 在LandscapeGUI控制器中,我添加了以下行: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOri

我有2个GUI和2个控制器 1称为LandscapeGUI控制器,第二个称为HighGUI控制器

现在,我通常调用HighGUI控制器,当我旋转iphone时,它会检测到,然后显示LandscapeGUI控制器: 代码:

问题是,然后动画将新窗口从iphone的另一侧推到窗口中

在LandscapeGUI控制器中,我添加了以下行:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
当我想回到HighGui控制器时,我调用:

[self dismissModalViewControllerAnimated:YES];
这一切工作,但只是在第二个动画我看到了正确的“旋转动画”。 你有什么建议吗

下面是一个简短的问题描述: 在1。动画从高到横向,横向被推到窗口中 但是在第二节。动画从横向到高,旋转看起来像一个真正的旋转

我希望1.0动画看起来像2。动画

致意
Ploetzeneder

听起来您希望序列如下所示:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
  if(fromInterfaceOrientation == UIInterfaceOrientationPortrait) {
    [self presentModalViewController:landscapeguicontroller animated:YES];
  }
  else {
    [self dismissModalViewControllerAnimated:YES];
  }
}
  • 以物理方式将设备从纵向旋转到横向
  • 将纵向视图(
    highguicontroller
    )设置为横向动画
  • 从屏幕的新“底部”向上推景观视图(
    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];
      }
    }
    
    这将在旋转动画完成后显示横向视图,然后在设备旋转回纵向后将其关闭

    希望有帮助

    为了避免“问题是,动画会将新窗口从iphone的另一侧推到窗口中。”,请尝试将视图控制器的modalTransitionStyle属性设置为以下任意属性之一: 类型定义枚举{ UIModalTransitionStyleCoverVertical=0, UIModalTransitionStyleFlipHorizontal, UIModalTransitionStyleCross溶解, }翻译风格

    此外,如果要避免动画旋转,可以设置shouldRotate。。。方法不允许其他方向,但随后设置为在设备实际更改方向时接收通知,并在处于适当方向时显示模态viewcontroller。请参阅苹果的“AlternateViews”示例代码以了解此示例

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