iOS 9:push/pop视图控制器被edgeForExtendedLayout破坏 [英] iOS 9: push/pop view controller broken by edgesForExtendedLayout

查看:50
本文介绍了iOS 9:push/pop视图控制器被edgeForExtendedLayout破坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 9上调试时,我发现了一个奇怪的问题.在View Controller的viewDidLoad中,我有这段代码:

I have found a strange issue while debugging on iOS 9. In my View Controller's viewDidLoad I have this piece of code:

if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
    self.edgesForExtendedLayout = UIRectEdgeNone;
}

当我按下或弹出一个新的视图控制器时,我注意到了一个奇怪的动画.过渡并不顺利,似乎正在显示视图控制器的堆栈"(您可以注意到两个图像的顶部甚至底部).

When I am pushing or popping a new view controller I have noticed a strange animation. The transition isn't smooth and it seems like it is displaying a "stack" of view controllers (you can notice the top and even slightly a bottom of both images).

我在iOS 7或iOS8上没有问题,这是新发布的iOS 9的错误还是我错过了一些东西?

I had no problem on iOS 7 or iOS8, is this a bug of the newly released iOS 9 or am I missing something?

值得一提的是,我正在使用自定义动画进行推送/弹出视图控制器转换.

It's also worth to mention that I am using custom animation for push/pop view controller transition.

这是被覆盖的UINavigationController方法之一的示例

Here is an example of one of the overriden UINavigationController methods

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    UIView *theWindow = self.view;
    [[theWindow layer] removeAllAnimations];

    if (animated) {
        CATransition *animation = [CATransition animation];
        [animation setDuration:0.25];
        [animation setType:kCATransitionFade];
        [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
        [[theWindow layer] addAnimation:animation forKey:@""];
    }

    [super pushViewController:viewController animated:NO];
}

编辑:

我已经调试了两个小时了.我已经按照iOS 7(navigationController:animationControllerForOperation:operation fromViewController:toViewController)中引入的视图控制器转换API重新实现了自定义动画,但是问题仍然存在.

I have been debugging this issue for couple of hours now. I have reimplemented the custom animations following API for view controllers transitions introduced in iOS 7 (navigationController:animationControllerForOperation:operation fromViewController:toViewController) but the issue persists.

如果过渡为alpha属性设置动画,则会发生问题.

The problem happens if the transition is animating alpha property.

您是否有解决此问题的想法?

Do you have an idea how to overcome this issue?

谢谢.

推荐答案

您需要为toViewController设置最后一帧. transitionContext.finalFrame(for:)可以帮助您确定它.像这样:

You need to setup final frame for toViewController. transitionContext.finalFrame(for:) can help you to determine it. Something like:

toViewController.view.frame = transitionContext.finalFrame(for: toViewController)

这篇关于iOS 9:push/pop视图控制器被edgeForExtendedLayout破坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆