매우 간단한 문제가 있지만이 버그의 원인을 찾을 수 없습니다. 어떤 아이디어라도 감사합니다.버그 오브젝트 이동 및 새 좌표 설정시 고정
그래서 객체가 UIImageView
이고 점 A (x1, y1)에서 점 B (x2, y2)까지 점 C (x2, y2)로 넘겨주세요.
내가 A에서 B로 C에서 D로 이동할 때 ... 애니메이션이 없으면 작동합니다!
나는 A로부터 이동는 C에게 B를 .... 등등 ... 애니메이션은 -> 버그가 있습니다!A부터 B까지의 작품들, B에서 C까지의 작품들만이 다른 곳에서 나타납니다.
는나는 기본적으로
//ADDING ANIMATION ==> Bug !
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"End of touch");
UITouch *touch = [[event touchesForView:self.view] anyObject];
CGPoint location = [touch locationInView:touch.view];
[self spinLayer:object.layer duration:1 direction:SPIN_CLOCK_WISE newFrame:location];
tempFrame = location; // tempFrame is global.
}
그리고 애니메이션의 끝에
, 내가 을 할 수 있습니다 ..touchesBegan
방법 및
touchesEnd
방법을 구현하고
//NO ANIMATION ==> Works !
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"End of touch");
UITouch *touch = [[event touchesForView:self.view] anyObject];
CGPoint location = [touch locationInView:touch.view];
object.center = CGPointMake(location.x, location.y);
}
으로 새 위치로 개체를 이동
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
object.center = tempFrame;
// I assign this because the object has to be updated to its new location to move it to points B, C, D and so forth...
// The object is actually at the desired point. But it appears on the SCREEN at a different location although it `NSLogs` at the right point.
}
내가
object.center = tempFrame;
내가 객체 (X2, Y2)에있을 것으로 예상 할당 할 때
:
이는 버그입니다. 그것은 기술적으로 (x2, y2)에 있습니다 (내가 NSlog
위치인데 알았지 만) 화면의 다른 곳에 나타납니다.
다시 점 C로 이동하면 (x2, y2)를 사용하고 올바르게 (x3, y3)로 이동하지만 화면의 다른 곳에 다시 나타납니다!
모든 아이디어 ??????
우리가 방법을 볼 수 있습니다 'spinLayer에 조각
을 변경 기간을 : 방향 : newFrame :'? – joerick
물론입니다. 그것의 간단한 애니메이션 ... http://pastebin.com/P0ypj7RY – Legolas
왜'transform.translate.X/Y' 대신에'position.x'와'postion.y' keypath에 애니메이션을 적용하지 않습니까? 애니메이션 위치를 확인하고 꽤 괜찮 았어 –