중단이 내 코드입니다UIPanGestureRecognizer이 시작 사이의 길이를 얻을
func respondsToPenGesture(sender: UIPanGestureRecognizer) {
let startLocation : CGPoint
if (sender.state == UIGestureRecognizerState.Began) {
startLocation = sender.locationInView(self.newEffectView)
}
else if (sender.state == UIGestureRecognizerState.Ended) {
let stopLocation = sender.locationInView(self.newEffectView)
let dx = stopLocation.x - startLocation.x;
let dy = stopLocation.y - startLocation.y;
let distance = sqrt(dx*dx + dy*dy);
NSLog("Distance: %f", distance);
}
}
나는이 길이를 사용하려면, 그것은 오류 보여줍니다 : 정수 'startLocation'은 초기화되기 전에 사용되었습니다.
내가 그것을 변경하는 경우 :
func respondsToPenGesture(sender: UIPanGestureRecognizer) {
//let startLocation : CGPoint
if (sender.state == UIGestureRecognizerState.Began) {
let startLocation = sender.locationInView(self.newEffectView)
}
else if (sender.state == UIGestureRecognizerState.Ended) {
let stopLocation = sender.locationInView(self.newEffectView)
let dx = stopLocation.x - startLocation.x;
let dy = stopLocation.y - startLocation.y;
let distance = sqrt(dx*dx + dy*dy);
NSLog("Distance: %f", distance);
}
}
이 표시됩니다 : 해결되지 않은 식별자의 사용 'startLocation'. (P.s : 스위치와 케이스를 사용하여 이미 시도했지만 동일한 문제가 있음) 누군가이 문제를 해결할 수 있습니까? Thx 사전에.
THX :-) 도움이
희망, 사람이 내가 통해 UR 대답하고 XmasRights의 답을 결합은, 마지막으로 내가 원하는 것을 얻을, 많은 도움이! – CizooDev
@CizooDev 기꺼이 도와 드리겠습니다.그들이 도움이된다면 당신은 둘 다 대답을 upvote 할 수있다. – alexburtnik