Hi everyone.
I am trying to catch when a specific UIPicker animation is finished.
I have looked long for an answer to this but it seems that the common answer, which is to ensure the selectRow call is within the beginAnimations and commitAnimations calls, does not work.
The problem is that the animationFinished is triggered almost immediately after the commitAnimations is called and long before the actual animation stops.
Thinking that the problem might be that the selectRow creates its own animation block and that I'm not actually tracking what I want, I tried calling selectRow with animated:NO hoping my own animation block would then take over the animation of the picker. This did indeed make the animationFinished trigger at the end of the animation but the animation itself became jerky.
How do I make sure that I'm tracking the correct animation or am I missing something else?
Any info would be greatly appreciated including curt references to appropriate documentation I might have missed.
Best regards, M@
This is the code:
- (void) animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context {
NSLog(@"animation %d stopped",animationID);
}
- (void)animateToRow:(UIPickerView *)pickerView toRow:(NSInteger)row inComponent:(NSInteger)component
{
[UIPickerView beginAnimations:@"1" context:nil];
[UIPickerView setAnimationDelegate:self];
[UIPickerView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
[pickerView selectRow:row inComponent:component animated:YES];
[UIPickerView commitAnimations];
}