调用多个animation,一个又一个相同的UIView对象,而不使用完成

UPATE开始

正确的答案在这里:
没有使用完成块,可以在UIView上做多个animation

没有必要读这个。

UPATE结束

我有类似的问题, UIView animateWithDuration立即返回 ,但我不能使用完成块,因为我的animation是在不同的function。

但是想要animation相同的对象。

我正在制作纸牌游戏,所以我在屏幕上移动牌,但在移动之间我也有一些游戏逻辑。 所以为什么把animation分开是很方便的。

如何解决这个问题?

@Fogmeister
完成的问题如下:
在方法1之后,方法2被调用。
如果我想调用method1 52次(因为我有52张牌),那么method2也会被调用52次。
但在我的情况下,我需要关注,调用method1 52次,比调用method2 4次…
所以我不明白这是怎么一回事。
也有时我需要method1后调用method2,但有时我需要调用方法1后的method3 …

我正在考虑在method1之后创build对象的深层副本,然后在新对象上调用method2。
这会工作吗?

@Fogmeister第二回应
我也得出了同样的结论。
但是我不喜欢以下原因。
我需要将游戏逻辑放在animation逻辑中,我希望事物能够松散耦合。
animation代码不应该处理游戏逻辑代码。

我想要做的是做多个animation,一个又一个相同的UIView对象,而不使用完成:,因为我不会保持animation代码简单,并重用它也。

如果你想你可以从我的代码下载
http://weborcode.com/dl/Tablic.zip
animation是在TBL_CardView.m文件方法animation中完成的*
它被称为:
TBL_GameViewController.m文件的方法gameStateMachineLoop所有的卡都从左到右洗牌,然后一张卡再次发送到左边。
但是问题在于,洗牌之前这张牌已经在右边了,如果你启动了这个项目,你将会select它。

没有太多的信息可以继续,但是您不必为每个animation制作一个animation。 如果你想animation所有的卡,然后使用一个animation,并更新animations块中的所有卡。

如果你想animation所有的卡片,然后其他东西,那么你可以做这样的事情…

 - (void)animateCards:(NSArray *)cards { // call this once and all of the cards in the array will animate over 5 seconds. [UIView animateWithDuration:5.0 animations:^{ for (Card *card in cards) { card.frame = // whatever } } completion:^(BOOL finished) { if (iNeedToCallMethod2) { [self doSomethingElse]; } else { [self somethingCompletelyDifferent]; } }]; } - (void)doSomethingElse { //this will only run after all the cards have animated //if the condition requires it to run [UIView animateWithDuration:5.0 animations:^{ for (Suit *suit in self.suits) { // not really sure what you want to do here // but you can do the same as above } } completion:^(BOOL finished) { }]; } - (void)somethingCompletelyDifferent { //this will run once only if the other method doesn't run } 

你所做的只是控制stream量。 不要想着在桌子周围移动卡片,而是多想想你有什么工具可用,以及如何使用它们使事情做你想做的事情。