1
길게 누르는 동안 작업을하려고합니다 (지금은 데이터를 인쇄하고 있습니다). 하지만 시뮬레이터/휴대 전화에서 길쭉한 동작을 할 때마다 여러 번 반복됩니다. 길게 누르는 제스처가 활성화 될 때마다 정확히 한 번만 작업을 수행하도록하려면 어떻게해야합니까?길게 누르기 제스처에서 여러 작업 수행
사과, 나는 iOS 개발에 상당히 익숙하다. 현재 상태로 여러 번 호출
@IBAction func addRegion(_ sender: Any) {
guard let longPress = sender as? UILongPressGestureRecognizer else
{ return }
let touchLocation = longPress.location(in: mapView)
let coordinate = mapView.convert(touchLocation, toCoordinateFrom: mapView)
let region = CLCircularRegion(center: coordinate, radius: 50, identifier: "geofence")
mapView.removeOverlays(mapView.overlays)
locationManager.startMonitoring(for: region)
let circle = MKCircle(center: coordinate, radius: region.radius)
mapView.add(circle)
print(coordinate.latitude)
print(coordinate.longitude)
//returns:
// 27.4146234860156
// 123.172249486142
// ... (a lot of these)
// 27.4146234860156
// 123.172249486142
}
을 그리고 필요한 경우'.changed' 상태를 확인하십시오. – rmaddy