Ho un set di animazioni di UIImageView che rappresentano un valore corrente e continuano a scorrere in alto ... idealmente non si fermano mai, anche nella vista è una scrollView o a quando sto scorrendo o zoomando nella scrollView, l'animazione si interrompe e si riavvia quando scrollView si arresta completamente. Credo che questo sia dovuto a un problema di threading dal momento che il ridisegno degli elementi avviene sul thread principale. All'inizio ho provato l'animazione UIView e quindi anche l'animazione core senza alcun effetto ... C'è un modo per avere la mia torta e mangiarla anch'essa?UIScrollView scroll block block Uiview animazione
ne e tutto l'aiuto sarebbe apprezzato
codice segue
- (void)TestJackpotAtRate:(double)rateOfchange
{
double roc = rateOfchange;
for (int i = 0; i < [_jackPotDigits count]; ++i)
{
roc = rateOfchange/(pow(10, i));
UIImageView *jackpotDigit = [_jackPotDigits objectAtIndex:i];
float foreveryNseconds = 1/roc;
NSDictionary *dict = @{@"interval" : [NSNumber numberWithFloat:foreveryNseconds],
@"jackPotDigit" : jackpotDigit
};
[NSTimer scheduledTimerWithTimeInterval:foreveryNseconds target:self selector:@selector(AscendDigit:) userInfo:dict repeats:YES];
}
}
-(void)AscendDigit:(NSTimer*)timer
{
NSDictionary *dict = [timer userInfo];
NSTimeInterval interval = [(NSNumber*)[dict objectForKey:@"interval"] floatValue];
UIImageView *jackpotDigit = [dict objectForKey:@"jackPotDigit"];
float duration = (interval < 1) ? interval : 1;
if (jackpotDigit.frame.origin.y < -230)
{
NSLog(@"hit");
[timer invalidate];
CGRect frame = jackpotDigit.frame;
frame.origin.y = 0;
[jackpotDigit setFrame:frame];
[NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(AscendDigit:) userInfo:dict repeats:YES];
}
[UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^
{
CGRect frame = [jackpotDigit frame];
double yDisplacement = 25;
frame.origin.y -= yDisplacement;
[jackpotDigit setFrame:frame];
}
completion:^(BOOL finished)
{
}];
}
Controllare questo thread SO http://stackoverflow.com/a/4136988/2315974 – danypata
Grazie mille ... Proprio quello di cui avevo bisogno – Genhain