ios - UIViewController PresentViewController 模式在 iOS7 中没有动画

标签 ios objective-c iphone animation presentviewcontroller

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

随后调用dismissViewControllerAnimated:completion:在所有 iOS 版本中都能正确呈现动画。

代码结构

调用当前方法的 View Controller 是UINavigationController的 Root View Controller 。 ,这个导航 Controller 是 viewControllers 之一在 UITabBarController

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

GenreViewController *controller = [[GenreViewController alloc] init]; [self presentViewController:controller animated:YES completion:nil];

尝试修复

  • 显式分派(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 - 通过模拟器进行应用内商店购买

ios - 实现 UIScrollView 时遇到问题

iphone - 带有自定义 View 选择器的 UIBarButtonItem init 无法正常工作

iphone - iOS5 中的 viewController 对象 BAD_ACCESS?

iphone - cocos2d中如何去除 Sprite ?

ios - uitabbarcontroller 在 xamarin iOS mono touch 中无法正常工作

ios - swift 中的 alertControllers

ios - 使用 UIDocumentPickerViewController,是否可以像在 Slack 中一样在首次打开时显示默认服务(Dropbox、Google Drive 等)?

ios - iOS Objective C 中的错误域=NSURLErrorDomain 代码=-1012 "(null)"

iphone - 数组未填充目录内容