如果在iOS中的NSNotificationCenter上声明 [英] If statement on NSNotificationCenter in iOS

查看:98
本文介绍了如果在iOS中的NSNotificationCenter上声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在结束时启动另一个动画。

I'm trying start another animation when one ends.

我正在检查这样的回调:

I am checking for callbacks like this:

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(animationDidStopNotification:) 
name:ImageAnimatorDidStopNotification 
object:animatorViewController];

如何在收到ImageAnimatorDidStopNotification时创建一个if语句来触发某些内容?

How do I make an if statement that lets me do trigger something when ImageAnimatorDidStopNotification is received?

谢谢!

推荐答案

您没有发布足够的代码来了解什么是你想要做什么以及问题在哪里。

You didn't post enough code to know what are you trying to do and where is the problem.

如果你想用UIKit链接两个(或更多)动画,请尝试使用 setAnimationDidStopSelector: selector。

If you want to chain two (or more) animations with UIKit, try using setAnimationDidStopSelector: selector.

- (void)startAnimating
{
    [UIView beginAnimations: @"AnimationOne" context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(animationOneDidStop:finished:context:)];
    /* animation one instructions */
    [UIView commitAnimations];
}

- (void)animationOneDidStop:(NSString*)animationID 
                   finished:(NSNumber*)finished 
                    context:(void*)context
{
    [UIView beginAnimations: @"AnimationTwo" context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(animationTwoDidStop:finished:context:)];
    /* animation two instructions */
    [UIView commitAnimations];
}

- (void)animationTwoDidStop:(NSString*)animationID 
                   finished:(NSNumber*)finished 
                    context:(void*)context
{
    [UIView beginAnimations:@"AnimationThree" context:nil]; 
    [UIView setAnimationDuration:1.0]; 
    /* animation three instructions */
    [UIView commitAnimations];
}

这篇关于如果在iOS中的NSNotificationCenter上声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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