简体   繁体   English

麻烦UIView,animateWithDuration并完成

[英]Trouble with UIView, animateWithDuration and finished

I don't know what's wrong with this piece of code. 我不知道这段代码有什么问题。

 [UIView animateWithDuration:10.0f delay:0.0f options:UIViewAnimationOptionTransitionNone animations:^{ CGAffineTransform transform = CGAffineTransformMakeScale(0.1, 0.1); self.transform = transform; } completion:^(BOOL finished) { if (finished) { NSLog(@"Animation finished"); [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"NSShowHomeScreen" object:nil ]; } }]; 

Even with a 10 second duration, I get the console message "Animation finished" immediately as the animation starts. 即使持续时间为10秒,我也会在动画开始时立即收到控制台消息“动画完成”。

I want to shrink / scale my first UIView and after that I'd like to show another UIView. 我想缩小/缩放我的第一个UIView,之后我想展示另一个UIView。 But now the 2nd UIView gets displayed well before the shrink ends. 但现在第二个UIView在收缩结束前显示得很好。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Thanks 谢谢

Sorry it was my bad. 对不起,这是我的坏事。 I was also using UIPinchGestureRecognizer which was causing the problems. 我也在使用导致问题的UIPinchGestureRecognizer。 Anyway appreciate your quick reply.. 无论如何,感谢您的快速回复..

Thanks 谢谢

In the UIView documentation, for the transform property, says: 在UIView文档中,对于transform属性,说:

Changes to this property can be animated. 可以对此属性的更改进行动画处理。 Use the beginAnimations:context: class method to begin and the commitAnimations class method to end an animation block. 使用beginAnimations:context:class方法开始,使用commitAnimations类方法结束动画块。 The default is whatever the center value is (or anchor point if changed) 默认值是中心值(或者如果更改了锚点)

so maybe it cant be animated using the block methods, and you will have to use begin and commit wrappers around the animation 所以也许它不能使用块方法进行动画处理,你将不得不在动画周围使用begin和commit包装器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM