- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用一些 UIViewController
包含在 UINavigationController
中.
一个人会收到一个推送 segue
来自UIButton
在 storyboard
上, 然后使用调用的滑动手势将其关闭
popViewControllerAnimated
我正在使用 UINavigationControllerDelegate
提供符合 UINavigationControllerDelegate
的自定义对象. animateTransition 的代码如下所示。
我的问题是,第一次运行时, View 会在呈现时显示动画,但之后每次都不会显示动画(它只是立即出现)。
有人能帮忙吗?
谢谢!
-(void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
//Get references to the view hierarchy
UIView *containerView = [transitionContext containerView];
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
if (self.isPresenting) {
[containerView insertSubview:toViewController.view belowSubview:fromViewController.view];
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
fromViewController.view.transform = CGAffineTransformMakeTranslation(-1000, 0);
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
} else if (!self.isPresenting) {
//Add 'to' view to the hierarchy
[containerView insertSubview:toViewController.view belowSubview:fromViewController.view];
//Scale the 'from' view down until it disappears
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
//toViewController.view.transform = CGAffineTransformMakeScale(1.0, 1.0);
fromViewController.view.transform = CGAffineTransformMakeScale(0.01, 0.01);
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}
}
最佳答案
升级到 iOS8 后,我遇到了一组类似的问题。需要检查的几件事:
确保在开始动画之前调用这些:
[toViewController beginAppearanceTransition:YES animated:YES];
[fromViewController beginAppearanceTransition:NO animated:YES];
然后在完成 block 中调用这些:
[toViewController endAppearanceTransition];
[fromViewController endAppearanceTransition];
[transitionContext completeTransition:finished];
需要以上内容来确保在正确的时间调用 viewWillAppear: 和 viewWillDisappear:。
希望这对您有所帮助。
干杯!
关于ios - 动画并不总是从 UIViewControllerAnimatedTransitioning 中的 animateTransition 可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25060943/
我是一名优秀的程序员,十分优秀!