Is it possible to add animation to a slider created by for loop?
I have create a UISlider for something like a "slider to unlock" element.
The animation I've written works well when it point to just one slider.
But I need to use a for loop to create sliders dynamically. And the
animation does not work, when I create the sliders add tags for the
sliders and add the animation function to the sliders in the for loop,
like this:
[slider addTarget:self action:@selector(UnlocklinkSlider:)
forControlEvents:UIControlEventTouchUpInside];
And the animation function is:
- (void)UnlocklinkSlider:(UISlider*)slider
{
for (int i = 0; i < rownumber; i++){
UIImageView *frontimg = (UIImageView *)[self.view
viewWithTag:i*10+1];
...
if (slider.tag==i*10) {
if(slider.value >= 0.5){
// user did not slide far enough, so return back to 0
position
[UIView beginAnimations: @"SlideCanceled" context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration: 0.35];
// use CurveEaseOut to create "spring" effect
[UIView setAnimationCurve: UIViewAnimationCurveEaseOut];
...
[UIView commitAnimations];
...
}
else{
...
}
}
}
}
But the animation does not work in this way.
No comments:
Post a Comment