passing objects to method of type CGFloat
Am I using the wrong types? CGFloat? float? int, all give me the same problem.
I need help with my method wiggleImage. I am trying setup a method that I can pass the objects in and have one method that I can call and animate many different views and reuse the code. But when I hard code the anchorPointX, and anchorPointY values inside the method, it works fine. When I use the values passed in, it does some strange conversion and as you can see from the log output, it changes the values to something other than what I am passing in.
- (void)viewDidLoad {
[self wiggleImage:candleFlickerView
duration:.45
curve:UIViewAnimationCurveEaseInOut
x:10.0
y:10.0
rotation:1
anchorPointX:0.2
anchor开发者_JAVA技巧PointY:0.2];
NSLog(@"VDL AnimationViewController....\n ");
}
- (IBAction)wiggleImage:(UIImageView *)image duration:(NSTimeInterval)duration
curve:(int)curve x:(CGFloat)x y:(CGFloat)y rotation:(CGFloat)rotation
anchorPointX:(CGFloat)anchorPointX anchorPointY:(CGFloat)anchorPointY
{
// UN HIDE THE VIEW
image.hidden = FALSE;
// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationRepeatCount:FLT_MAX];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationRepeatAutoreverses:YES];
//image.layer.anchorPoint= CGPointMake(0.5,0);
image.layer.anchorPoint= CGPointMake(anchorPointX, anchorPointY);
// The transform matrix
CGAffineTransform transform = CGAffineTransformMakeRotation(-0.45);
image.transform = transform;
// Commit the changes
[UIView commitAnimations];
NSLog(@"VDL showing wiggleImage Animation with Values of....\n ");
NSLog(@"\nX=[%f]", anchorPointX );
NSLog(@"\nY=[%f]", anchorPointY );
NSLog(@"\nRotation=[%f]", rotation );
}
console output.
2011-10-07 10:21:54.580 Skippy[16932:c803] VDL showing wiggleImage Animation Values....
2011-10-07 10:21:54.581 Skippy[16932:c803]
X=[2.562500]
2011-10-07 10:21:54.582 Skippy[16932:c803]
Y=[0.000000]
2011-10-07 10:21:54.582 Skippy[16932:c803]
Rotation=[0.000000]
2011-10-07 10:21:54.583 Skippy[16932:c803] VDL AnimationViewController....
Is wiggleImage
declared before it is used in viewDidLoad
? Make sure it is present in the header for your class, and that the header is included in the implementation file.
精彩评论