Reputation: 203
I want to display the image position while it is animating. the Animation code is shown here,
[UIImageView beginAnimations:nil context:NULL];
[UIImageView setAnimationDuration:2];
[UIImageView setAnimationRepeatAutoreverses:YES];
[UIImageView setAnimationRepeatCount:20];
CGPoint poss;
poss.x=150;
poss.y=328;
img2.center=poss;
[UIImageView commitAnimations];
Can any one tell me how to display the image position every microsecond in NSLog.
Upvotes: 1
Views: 90
Reputation: 2589
Put timer function that calls a method having the below line and declare the img2 at class level at every microsecond or while you want to display
[NSTimer scheduledTimerWithTimeInterval:(2/1000000) target:self selector:@selector(Log) userInfo:nil repeats:NO];
-(void)Log {
NSLog(@"X:%f \n Y:%f",img2.center.x,img2.center.y);
}
Upvotes: 1
Reputation: 3564
You can set the animation delegate object setAnimationDelegate: for receiving the start- and stop-message from your animation. In that functions you should set a BOOL that you can determine if the animation is still active.
To get the position write a function that would called with the help from an NSTimer, that log the position of your image if the animation is active, otherwise disable the timer.
Hope that helps...?
Upvotes: 1