0
잘못된 유형을 사용하고 있습니까? CGFloat? 흙손? int, 모두 나에게 같은 문제를 준다.CGFloat 유형의 메소드에 객체 전달
내 방법 wiggleImage에 대한 도움이 필요합니다. 설치 프로그램에서 객체를 전달할 수있는 방법을 시도하고 있으며 여러 다른 뷰를 호출하고 애니메이션을 적용하고 코드를 재사용 할 수있는 한 가지 방법이 있습니다. 그러나 anchorPointX 및 anchorPointY 값을 메서드 내부에 하드 코딩하면 올바르게 작동합니다. 그 전에 내가 전달 된 값을 사용하는 경우, 그것은 이상한 변환을 수행하고 로그 출력에서 볼 수 있듯이, 그것은 내가 전달하고있는 무슨 이외의 다른 값을 변경합니다.
- (void)viewDidLoad {
[self wiggleImage:candleFlickerView
duration:.45
curve:UIViewAnimationCurveEaseInOut
x:10.0
y:10.0
rotation:1
anchorPointX:0.2
anchorPointY: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....
신성한 매개 변수 spew! 이것은 C++가 아닙니다. wiggleImage가 IBOutlet 인 이유는 무엇입니까? 이것은 단지 호기심이 중요하지 않아야합니다. 또한 콘솔 로그 메시지가 코드에 표시된 것과 일치하지 않습니다. 정확합니까? 로그에서 해당 값을 정확하게 출력해야합니다. 작은 문제는 회전이 int로 간주되어 전환이 진행될 수 있습니다. – EricLeaf
코드를 사용해 보았지만 제대로 작동합니다. 이것은 플로트를 올바르게 출력합니다. – Perception