【问题标题】:Two-stage rotation animation is deprecated. This application should use the smoother single-stage animation不推荐使用两阶段旋转动画。此应用程序应使用更流畅的单阶段动画
【发布时间】:2023-11-04 06:20:01
【问题描述】:

我正在构建一个 ipad 应用程序。当应用程序启动时,我以横向右模式显示它。但是一旦应用程序启动,我就会收到此消息

Two-stage rotation animation is deprecated. This application should use the smoother single-stage animation

我在所有课程中都使用了这种方法

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

我还在我的 plist 文件中将支持的界面方向 (iPad) 设置为横向。 如何解决此警告消息?

【问题讨论】:

  • 如果您尝试使用模态 UITabBarController(更新。是的,您会这样做),请参阅解决方案 here。官方解释为什么会这样here.
  • @Alexander 我没有以模态方式显示标签栏。
  • 您的“登录屏幕”是 NavigationController 吗?所有控制器,必须是“rootViewController”,不应用作“模态”。
  • @Alexander LoginScreen 显示为标签栏控制器的模式。添加到标签栏控制器的所有其他控制器都在导航控制器下作为 rootViewControllers。登录时我关闭登录模式以显示标签栏

标签: ipad uiinterfaceorientation ios5.1


【解决方案1】:

我刚刚意识到 - 在阅读 this 答案后 - 我只是错误地使用了标签栏控制器:标签栏应该只用作根控制器,但是我在它之前插入了一个导航控制器。

【讨论】:

  • 似乎标签栏控制器可以在iOS8的导航控制器中使用,但在iOS7中出现错误。
【解决方案2】:

如果您在情节提要中以空标签栏控制器作为根运行应用程序,也可能会收到此错误消息。我刚刚开始使用一个应用程序,我的UITabBarController 还没有视图控制器,但正在呈现一个登录模式。

【讨论】:

  • 我有这个。谢谢。
【解决方案3】:

问题在于您的应用正在使用以下方法之一,这些方法在 iOS 5.0 中已被弃用:

didAnimateFirstHalfOfRotationToInterfaceOrientation:
willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:
willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:

您需要修改视图控制器以覆盖 willAnimateRotationToInterfaceOrientation:duration:,并且覆盖任何“HalfOfRotation”方法。

【讨论】:

  • 我在哪里放置这个方法。
  • 我的应用程序究竟做了什么——我有一个标签栏应用程序。我在我的 appdelegate 中初始化了一个 tabbarcontroller,并将我的所有类添加到 tabbarcontroller 数组中。然后我在标签栏的前面添加一个登录屏幕,登录后我显示标签栏。我的应用程序以横向模式打开,但我收到此警告。我也认为因此我的键盘尺寸不正确。在横向模式下显示键盘宽度和高度时,它在 ipad 3 中给了我宽度 = 352 和高度 = 1024。我似乎系统不知道它当前处于横向模式。谢谢
  • 您是否在所有源代码中搜索了那些已弃用的方法?
  • 是的。实际上这些方法并没有出现在我的代码中。
  • 至少从 6.0 开始 willAnimateRotationToInterfaceOrientation:duration: 也会触发这个......有时,我有两个项目只有 willAnimateRotationToInterfaceOrientation:duration: 没有别的,一个会产生通知,另一个不会,必须有笔尖的杂物导致它。
【解决方案4】:

检查标签栏的数组声明 ..你可能犯的错误: 我在分配后声明了数组对象

tabBarController.viewControllers = tabControlArry;
[tabControlArry addObject:navCOntroller];
[tabControlArry addObject:navController1];

正确方法:

[tabControlArry addObject:navCOntroller];
[tabControlArry addObject:navController1];
tabBarController.viewControllers = tabControlArry;

【讨论】:

    【解决方案5】:

    此错误消息与 TabBarController 的使用有关。当您没有将 tabBarController 设置为应用的 “根控制器” 时,您可能会遇到此错误。所以让你的 TabBarController 作为根控制器 & 这个错误不会再困扰你了。

    【讨论】:

      最近更新 更多