iphone setAnimationWillStartSelector / setAnimationDidStopSelector nicht (a Scrolling Ticker Beispiel) Arbeits

StackOverflow https://stackoverflow.com/questions/1808320

  •  05-07-2019
  •  | 
  •  

Frage

Ich bin ein Ticker am unteren Rand einer Ansicht (man denke an einen Nachrichtensender Schlagzeilen-Ticker bar) in Form eines horizontalen Scrollview anzeigt. Es funktioniert richtig, wenn ich die repeat auf unendlich gesetzt, aber ich möchte eine andere Funktionalität in der Lage sein zu tun, wenn die Animation beginnt und stattdessen stoppt. Doch nach der Dokumentation und viele Beispiele Online lesen, kann ich nicht setAnimationWillStartSelector / setAnimationDidStopSelector erhalten reagieren zu können.

Hier ist mein Code:

- (void)animateView {    
[UIScrollView setAnimationDelegate:self];    
[UIScrollView setAnimationWillStartSelector:@selector(animationStart:context:)];    
[UIScrollView setAnimationDidStopSelector:@selector(animationStop:finished:context:)];    
[UIScrollView beginAnimations:@"pan" context:nil];    
[UIScrollView setAnimationDuration:10.0f];    
[UIView setAnimationRepeatCount:1];    
[UIView setAnimationBeginsFromCurrentState:YES];    
[UIScrollView setAnimationCurve:UIViewAnimationCurveLinear];    
tickerScrollView.contentOffset = CGPointMake(textLabelRect.size.width,0);    
[UIScrollView commitAnimations];    
}    
- (void)animationStart:(NSString *)animationID context:(void *)context {    
NSLog(@"animationWillStart");    
}
- (void)animationStop:(NSString *)animationID finished:(BOOL)finished context:(void *)context {    
NSLog(@"animationDidStop");    
[self animateView];    
}

Im Moment ist dieser Code in meiner UIViewController Unterklasse. Allerdings habe ich auch versucht, alles in meiner AppDelegate setzt auch, während auch offensichtlich die setAnimationDelegate ändern. Ich habe verschiedene animationDurations versucht, mit, repeatCounts, usw., aber noch kein Glück.

wirklich jede mögliche Hilfe schätzen würde. Dank

War es hilfreich?

Lösung

Sie können versuchen, die setAnimationDelegate, setAnimationWillStartSelector und setAnimationDidStopSelector innerhalb der Animation Block setzen. Gemäß der iPhone O Reference Library Dokumentation haben diese Methoden in der Animation Block in Ordnung gebracht werden, damit es funktioniert.

Hope, das hilft! AOB

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top