簡體   English   中英

Cocoa setAnimationDidStopSelector

[英]Cocoa setAnimationDidStopSelector

目前我有這個代碼工作正常

[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:)];

這給了我一個錯誤。

謝謝,Tee

傳遞給選擇器的字符串是您在此方法調用中使用的字符串:

[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
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM