iphone - cocoa setAnimationDidStopSelector

标签 iphone objective-c

目前我有这段代码可以正常工作

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

- (void)animationDone:(NSString *)animationID finished:(BOOL)finished context:(void *)context {
// do stuff here
}

记录 animationID 的值给我一个 null。

如何将值传递给@selector?

我试过了

[UIView setAnimationDidStopSelector:@selector(animationDone:@"animation1"finished:context:)];

这给了我一个错误。

谢谢, 三通

最佳答案

传递给选择器的字符串是您在此方法调用中使用的字符串:

[UIView beginAnimations:@"your_animation_name_here" context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
// whatever changes here
[UIView commitAnimations];

之后,您可以这样做:

- (void)animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context
{
    if ([animationID isEqualToString:@"your_animation_name_here"])
    {
        // something done after the animation
    }
}

关于iphone - cocoa setAnimationDidStopSelector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1999515/

相关文章:

iphone - 核心数据。 ExecuteFetchRequest 出现故障 NSManagedObject(不在 RAM 中)

objective-c - ASIHTTPRequest 在中断 Internet 连接后导致崩溃

objective-c - isMemberOfClass 不能按预期使用 ocunit

objective-c - 弹出 NavigationController 时应用程序崩溃!

ios - 需要在 UIActivitycontroller 中显示腾讯微博图标

iPhone SDK : How to implement a signature capture?

iphone - 当用户不响应推送通知时会发生什么?

iPhone 联系人应用示例

iphone - 我的 Objective C 代码中只需要一个版本吗?

ios - 基于 block 的 KVO : Block-KVO vs THObserversAndBinders vs KVOController