调用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 (只是为了看看会发生什么)
在每种情况下,行为都没有改变。
任何帮助将不胜感激!
更新 - 修复
事实证明UITabBarController
有modalPresentationStyle
属性设置为 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/