1

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).

enter image description here first issue

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.

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];
}

EDIT:

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.

The problem happens if the transition is animating alpha property.

Do you have an idea how to overcome this issue?

Thanks.

skornos
  • 3,121
  • 1
  • 26
  • 30
  • Noticed the same thing using custom push animation. If you leave the screen and get back(or if you leave the default animation), it lays out just fine, but for some reason UIViewController ignores edgesForExtendedLayout when performing custom animations. – Mercurial Oct 09 '15 at 08:09
  • I overcame this issue by setting background color for navigation bar in each navigation controller `navigationController.navigationBar setBackgroundColor:[UIColor whiteColor]` – skornos Oct 09 '15 at 11:33
  • Related question: "[edgesForExtendedLayout ignored on iOS9 when using custom animation](https://stackoverflow.com/questions/33109454/edgesforextendedlayout-ignored-on-ios9-when-using-custom-animation)". – Gary May 22 '17 at 09:08

1 Answers1

1

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)
Viktor Kucera
  • 6,177
  • 4
  • 32
  • 43