jjzjj

ios - UIViewController presentViewController 模态在 iOS7 中没有动画

coder 2024-01-18 原文

调用 presentViewController:animated:completion: 不会在 iOS7 中设置动画。 View 立即出现。动画在 iOS8 中正常工作。在我的应用程序中的三个不同位置调用了当前方法,它们都显示了此行为。它发生在设备和模拟器上。

随后对 dismissViewControllerAnimated:completion: 的调用在所有 iOS 版本中都可以正确设置动画。

代码结构

调用当前方法的 View Controller 是 UINavigationController 的 Root View Controller ,而该导航 Controller 是 UITabBarControllerviewControllers 之一

每次调用都很简单,只需按下按钮即可触发。这是其中一个案例:

GenreViewController *controller = [[GenreViewController alloc] init]; [ self 呈现 View Controller :动画 Controller :是完成:无];

尝试修复

  • 显式分派(dispatch)到主线程
  • 在演示之前调用[UIView setAnimationsEnabled:YES]
  • 添加延迟以显示 Controller (只是为了看看会发生什么)

在每种情况下,行为都没有改变。
任何帮助将不胜感激!

更新 - 修复

事实证明,UITabBarControllermodalPresentationStyle 属性设置为 UIModalPresentationCurrentContext。这在 iOS7 中不会显示动画,您必须改用 UIModalPresentationFullScreen 的呈现样式。

最佳答案

你可以用这个

   GenreViewController *addController = [[GenreViewController alloc]

                       init];
   UINavigationController *navigationController = [[UINavigationController alloc]

                             initWithRootViewController:addController];

   [self presentViewController:navigationController animated:YES completion: nil];

关于ios - UIViewController presentViewController 模态在 iOS7 中没有动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31160738/

有关ios - UIViewController presentViewController 模态在 iOS7 中没有动画的更多相关文章

随机推荐