Mam zestaw animacji UIImageView, które reprezentują bieżącą wartość i stale utrzymuje tykanie w górę ... najlepiej nigdy się nie zatrzyma, także w widoku jest scrollView lub do i kiedykolwiek przewijam lub powiększam w scrollView animacja zatrzymuje się i uruchamia się ponownie, gdy scrollView przestaje się całkowicie poruszać. Wierzę, że jest to spowodowane problemem wątku, ponieważ przerysowywanie elementów odbywa się w głównym wątku. Na początku próbowałem animacji UIView, a nawet animacji rdzenia bez skutku ... Czy istnieje sposób na zjedzenie mojego ciasta i zjedzenie go?UIScrollView bloków zdarzeń przewijania UIView animacji
Wszelka pomoc będzie mile widziane
kod następująco
- (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)
{
}];
}
Sprawdź to Wątek http://stackoverflow.com/a/4136988/2315974 – danypata
Dziękuję bardzo ... Właśnie to, co potrzebne – Genhain