连续翻转视图 [英] fliping view continiously

查看:84
本文介绍了连续翻转视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

[UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.5];  
    if ([sender tag] == 1) {
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:placeholder cache:YES];
    }
    else {
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
    }
    if (view1OnTop) {
        [view1 removeFromSuperview];
        [placeholder addSubview:view2];
    }
    else {
        [view2 removeFromSuperview];
        [placeholder addSubview:view1];
    }
    [UIView commitAnimations];

    view1OnTop = !view1OnTop;

我想连续翻转视图,例如持续1分钟。

i want to continuously flip the view, for say some duration 1 min.

应该不断翻转。

我该怎么做。
我想的是,我想要一个视图,它应该在特定的时间内不断翻转。
我怎么能做到这一点?
的问候

how can i do it. what i m trying to is, i want a view, which should be continuously flipping for some particular amount of time. how can i achieve this? regards

推荐答案

除了翻转动画(我假设您已经使用过)之外,还需要启动一个新动画当当前的操作完成时。

Apart from the flipping animation, which I presume you have working, you need to initiate a new animation when the current one is finished.

在[UIView commitAnimations]之前,执行以下操作:

Before [UIView commitAnimations], do this:

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDone:finished:context:)];

添加功能

-(void)animationDone:(NSString*)id finished:(NSNumber*)n context:(void*)context

,然后进行下一轮射击。

and let that fire the next round.

编辑:您可以通过输入代码来实现来触发动画,因此从 [UIView beginAnimations ...] [UIView commitAnimations] 的典型块。当然,更好的解决方案是将动画开始代码放在单独的函数中,因此轮廓将如下所示:

edit: you do this by putting in the code to fire an animation, so the typical block from [UIView beginAnimations...] to [UIView commitAnimations]. The better solution of course is to put the animation starting code in a separate function, so the outline will look like:

...
    [self startAnimationLoop];
...

-(void)startAnimationLoop
{
    [UIView beginAnimtions...];

    // do the animation stuff

    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationDone:finished:context:)];
    [UIView commitAnimations];
}

-(void)animationDone:(NSString*)id finished:(NSNumber*)n context:(void*)context
{
    [self startAnimationLoop];
}

使其返回/添加,添加一些状态变量或创建2这些互相调用的函数集( startAnimationLoop1 startAnimationLoop2 ,在完成后各触发另一个)

to make it go back/forth, add some state variable, or create 2 sets of these functions which call eachother (startAnimationLoop1 and startAnimationLoop2, each one firing the other when done)

这篇关于连续翻转视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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