12
votes

I have a viewcontroller with a view that I am dismissing using a UIView animation to scale it down to 0 before removing it. My code for dismissing it is:

[UIView animateWithDuration:_dismissAnimationDuration
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^(void) {
                     _menuContainerView.transform = CGAffineTransformMakeScale(0.0, 0.0);
                 }
                 completion:^(BOOL finished){
                     if ([_delegate respondsToSelector:@selector(popUpMenuDidClose)])
                     {
                         [_delegate popUpMenuDidClose];
                     }

                     [self.view removeFromSuperview];
                     [self removeFromParentViewController];
                 }];

That works perfectly when building from XCode 5 onto devices running both iOS 7 and iOS 8. But, as soon as I build to iOS 8 from XCode 6 (beta 6 and beta 7) the view just cuts away instead of animating. If that wasn't weird enough as soon as I change the target scale to (0.001, 0.001) it animates fine regardless of XCode version. Any ideas as to why I can't animate to an actual (0.0, 0.0) scale with XCode 6?

2
I have the same problem with the iOS8GM... no idea how to fix this. - Manuel M.

2 Answers

11
votes

So after speaking with a developer at Apple the reasoning I got back was that some base frameworks need to work with the inverses of transform matrices quite often, and since there is no inverse for the zero matrix the animation just returns out to avoid crashing. Hopefully this post has helped others who ran into a similar situation.

6
votes

If acceptable for you, set the scale values to 0.01 like so:

_menuContainerView.transform = CGAffineTransformMakeScale(0.01, 0.01);

Reference