麻烦的UIView,animateWithDuration及成品 [英] Trouble with UIView, animateWithDuration and finished
问题描述
,我不知道这有什么错这块code的。
[UIView的animateWithDuration:10.0f延迟:0.0选项:UIViewAnimationOptionTransitionNone动画:^ {
CGAffineTransform变换= CGAffineTransformMakeScale(0.1,0.1);
self.transform =变换;
}
完成:^(BOOL完){
如果(成品){
的NSLog(@动画完成);
[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@NSShowHomeScreen的对象:无];
}
}];
块引用>即使有一个持续10秒,我得到的控制台消息动画完成立即为动画开始。
我要缩小/扩大我的第一个的UIView之后,我想显示另一个UIView的。但是现在的第二UIView的被收缩结束前显示良好。
任何帮助将大大AP preciated。
感谢
解决方案在UIView的文档中,转换属性,说:
这个属性的更改可以制作动画。使用
beginAnimations:context:类方法来开始和
commitAnimations类方法来结束一个动画块。默认
无论是中心值(如果更改或锚点)
块引用>所以也许它不能使用块的方法是动画,你将不得不使用开始和提交包装围绕动画
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.
I want to shrink / scale my first UIView and after that I'd like to show another UIView. But now the 2nd UIView gets displayed well before the shrink ends.
Any help would be greatly appreciated.
Thanks
解决方案In the UIView documentation, for the transform property, says:
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. 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
这篇关于麻烦的UIView,animateWithDuration及成品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!