在继续播放其他类的动画之前,我该如何等待? [英] How do i wait until an animation in a different class is finished before continuing?

查看:57
本文介绍了在继续播放其他类的动画之前,我该如何等待?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下简单代码:

[otherClass doMethodOneWhichHasAnimation];

,该动画持续0.8秒.紧随其后的是推送视图控制器的代码:

and that animation lasts 0.8 seconds. Followed by code that pushes a viewcontroller:

SchemeView *schemeView = [[SchemeView alloc] init];
    [self.navigationController pushViewController:schemeView animated:YES];
    [schemeView release];

问题是,它不等待就推送视图控制器,我希望它等待.延迟只会延迟整个过程,包括从开始播放第一个动画开始.

The problem is, it pushes the viewcontroller without waiting, and I'd like it to wait. Doing delay just delays the whole thing, including the first animation from starting.

我如何让它等待0.8秒再运行第二位代码?

How can i get it to wait the 0.8 seconds before running the second bit of code?

推荐答案

您可以在动画制作完成后进行推送

You can push after the animation is done

[UIView animateWithDuration:0.8
        animations:^{ 
            // Animation
        } 
        completion:^(BOOL finished){

          // PushView

        }];

表示<iOS 4+看一下setAnimationDidStopSelector

for < iOS 4+ take a look at setAnimationDidStopSelector

[self performSelector:@selector(metohodToPushView) withObject:nil afterDelay:0.8];

这篇关于在继续播放其他类的动画之前,我该如何等待?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆