Ich versuche, ein Bild in einer UITableViewCell-Unterklasse zu animieren. Es funktioniert, wenn der Abgriff auf der Zelle etwa 1/2 Sekunde oder länger dauert. Für kürzere Taps wird die Zelle ausgewählt, aber meine Animation wird nicht ausgeführt.UITableViewCell - unterschiedliches Verhalten abhängig von der Touchdauer?
In meiner Ansicht-Controller, die ich habe:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ImageCell *cell = (ImageCell*)[tableView cellForRowAtIndexPath:indexPath];
cell.imageFlashDuration = 5.0;
cell.imageFlashNumberOfFrames = 25;
NSLog(@"Flash image...");
[cell flashImage];
[self performSelector:@selector(doSomething:) withObject:video afterDelay:5.0];
}
In meinem Imagecell:
-(void)flashImage {
UIImage *image = imageView.image;
if(imageView.isAnimating) {
NSLog(@"Stop animating");
[imageView stopAnimating];
}
NSMutableArray *animationArray = [NSMutableArray arrayWithCapacity:imageFlashNumberOfFrames];
for(int i=0; i<imageFlashNumberOfFrames; i++) {
[animationArray addObject:(i % 2 == 0? black60x60Image : image)];
}
imageView.animationImages = animationArray;
imageView.animationDuration = imageFlashDuration;
NSLog(@"> Start animating");
[imageView startAnimating];
}
In meinem log, ich sehe
2009-07-02 22:02 : 55.907 MyProg [1797: 20b] Flashbild ...
2009-07-02 22: 02: 55.912 Mein Prog [1797: 20b]> Start
2009-07-02 22 Animieren: 02: 59,455 myprog [1797: 20b] Flash-Image ...
2009-07-02 22: 02: 59,460 myprog [ 1797: 20b]> Start animieren
2009-07-02 22: 03: 02,463 myprog [1797: 20b] Flash-image ...
2009-07-02 22: 03: 02,468 myprog [1797: 20b]> Start animieren
2009-07-02 22: 03: 05,009 myprog [1797: 20b] Flash-image ...
2009-07-02 22: 03: 05,014 myprog [1797: 20b]> Start
Die obige Animieren war aus einer Mischung von 'kurz' und 'lang' berührt. Die langen Berührungen führten zur Zellenauswahl und Bildanimation, und die kurzen Berührungen führten zu einer Zellenauswahl ohne Animation.
Zusätzlich, wenn auf ein kurzes Antippen gefolgt von einem weiteren kurzen Antippen der Zelle, beginnt die Animation.
Haben Sie jemals eine Lösung finden? –
Nein. Das Verhalten ist je nach Gerät unterschiedlich. Auf einem älteren (vor 3GS) iPhone passiert die Animation gar nicht. Auf einem 6 Monate alten iPod Touch ist das obige Verhalten zu sehen. Ich habe es nicht auf einem 3GS versucht. – edoloughlin