Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何制作可重复的嵌套UIView动画?_Iphone_Objective C_Animation_Uiview_Repeat - Fatal编程技术网

Iphone 如何制作可重复的嵌套UIView动画?

Iphone 如何制作可重复的嵌套UIView动画?,iphone,objective-c,animation,uiview,repeat,Iphone,Objective C,Animation,Uiview,Repeat,我需要在鸟类图像显示为小像素的地方设置鸟类飞行动画,然后增长并移动到动画的中点。在那之后,鸟收缩回到小像素,但向前移动直到到达终点。我需要这个动画是可重复的。我用了两个动画:第一个是增加图像并移动,在整个块中,第二个是缩小并移动。第一个动画具有重复选项,即recond beginFromCurrentState。问题是从未调用过完整的块。我遗漏了什么,也许完整的块不适用于可重复的动画?这是我的密码: [UIView animateWithDuration:4.0 delay:0 options:

我需要在鸟类图像显示为小像素的地方设置鸟类飞行动画,然后增长并移动到动画的中点。在那之后,鸟收缩回到小像素,但向前移动直到到达终点。我需要这个动画是可重复的。我用了两个动画:第一个是增加图像并移动,在整个块中,第二个是缩小并移动。第一个动画具有重复选项,即recond beginFromCurrentState。问题是从未调用过完整的块。我遗漏了什么,也许完整的块不适用于可重复的动画?这是我的密码:

[UIView animateWithDuration:4.0 delay:0 options:(UIViewAnimationCurveEaseIn | UIViewAnimationOptionRepeat | UIViewAnimationOptionAllowUserInteraction) animations:^{
    self.bird1.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1, 1);
    self.bird1.center = bird1MiddlePoint;

} completion:^(BOOL finished){if (finished){

    NSLog(@"doesn't get called");
    [UIView animateWithDuration:4.0 delay:0 options:(UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction) animations:^{

        self.bird1.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.1, 0.1);
        self.bird1.center = bird1EndPoint;} completion:^(BOOL finished){if (finished && !self.gameManager.isPlaying){

            [UIView setAnimationRepeatCount:0];
            [self.bird1 removeFromSuperview];

    }}];        
}}];  

如果父动画无限期重复,因为您设置了
UIViewAnimationOptionRepeat
,它永远不会调用完成块,因为它永远不会完成。就这么简单。

如果父动画无限期地重复,因为您设置了
UIViewAnimationOptionRepeat
,它永远不会调用完成块,因为它永远不会完成。就这么简单。

如果完整的块甚至可以用于重复的动画,那就更符合逻辑了;)因为现在不可能嵌套内部动画(至少使用UIView动画),所以我有一个朋友叫CAKeyframeAnimation。我想你应该见见他。顺便说一句,有一些变通方法可以使用延迟选项来查看动画块,这样你就不必使用完成块,但我不建议你这样做,特别是如果你连续地为相同的属性设置动画。你还可以做些别的事情,只是想到了。您必须将单独隐藏的整个动画代码放置在某个“动画方法”中。但是,您可以使用与之前相同的方式嵌套动画,而无需使用
UIViewAnimationOptionRepeat
,这样整个动画每次调用只运行一次。然后,在最后一个完成块中调用动画方法,使其递归运行。谢谢。事实上,我已经尝试过递归调用,但在2-3个动画之间出现了一些闪现:如果完整的块甚至可以用于重复的动画,那就更符合逻辑了;)因为现在不可能嵌套内部动画(至少使用UIView动画),所以我有一个朋友叫CAKeyframeAnimation。我想你应该见见他。顺便说一句,有一些变通方法可以使用延迟选项来查看动画块,这样你就不必使用完成块,但我不建议你这样做,特别是如果你连续地为相同的属性设置动画。你还可以做些别的事情,只是想到了。您必须将单独隐藏的整个动画代码放置在某个“动画方法”中。但是,您可以使用与之前相同的方式嵌套动画,而无需使用
UIViewAnimationOptionRepeat
,这样整个动画每次调用只运行一次。然后,在最后一个完成块中调用动画方法,使其递归运行。谢谢。实际上,我已经尝试过递归调用,但在2-3个动画之间出现了一些闪现: