iOS: Wie zu erkennen, wenn eine animation beendet ist?
Gibt es eine Methode um zu erkennen, wenn eine animation beendet ist? Ich will rufen [nav setTitle:navItem]
wenn die animation fertig ist.
Hier unten ist ein Ausschnitt von meinem code. Hoffe die Frage ist klar genug, so kann ich bekommen eine Lösung, und am besten ein Beispiel.
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{
if(event.subtype == UIEventSubtypeMotionShake){
NSString *imageUrl = @"";
NSString *navItem = @"";
int randomNumber = arc4random() % 3;
switch (randomNumber) {
case 0:
imageUrl = @"pic1.png";
navItem = @"txt1";
break;
case 1:
imageUrl = @"pic2.png";
navItem = @"txt2";
break;
case 2:
imageUrl = @"pic3.png";
navItem = @"txt3";
break;
default:
break;
}
animation.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"pic1.png"],
[UIImage imageNamed:@"pic3.png"],
[UIImage imageNamed:@"pic2.png"],
[UIImage imageNamed:@"pic1.png"],
[UIImage imageNamed:@"pic2.png"],
[UIImage imageNamed:@"pic3.png"],
[UIImage imageNamed:imageUrl],
nil];
UIImage *img = [UIImage imageNamed:imageUrl];
[imageview setImage:img];
[animation setAnimationRepeatCount:1];
animation.animationDuration = 1;
[animation startAnimating];
[nav setTitle:navItem];
}
}
Wenn du eine Antwort löst Ihr problem, es ist gut, es zu akzeptieren, und Sie bekommen 2 Ruf-Punkte.
InformationsquelleAutor thar | 2011-10-14
Du musst angemeldet sein, um einen Kommentar abzugeben.
Können Sie die setAnimationDidStopSelector delegieren.
http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CAAnimation_class/Introduction/Introduction.html
Es funktioniert nicht für animationImages Art animation.
InformationsquelleAutor Michael D. Irizarry
Die animation ist abgeschlossen, wenn
[animation isAnimating]
== NEIN.Wenn Sie wollen, zu warten, bis es fertig ist, aber nicht sperren Sie die Benutzeroberfläche:
Sollte das das problem lösen, "akzeptieren" der Antwort: meta.stackexchange.com/questions/5234/...
Dies scheint nicht mehr zu funktionieren: stackoverflow.com/questions/3144300/...
Wohl jetzt am besten zu verwenden:
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
InformationsquelleAutor zaph
Dass einfach davon ausgegangen, dass die animation wird komplett in die Menge der Zeit, die Sie erzählt.
InformationsquelleAutor morningstar