Reputation: 1097
I have the following code and no error when I run this. long press is working fine and double tap is not working. I have disabled the zoom before adding the double tap gesture.
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
manager = CLLocationManager()
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation()
routeMapView.zoomEnabled = false
routeMapView.showsPointsOfInterest = true
let doubleTapGesture = UITapGestureRecognizer(target: self, action: "routeMapDoubleTapSelector:")
doubleTapGesture.numberOfTapsRequired = 2
routeMapView.addGestureRecognizer(doubleTapGesture)
let ulpgr = UILongPressGestureRecognizer(target: self, action:"routeMapLongPressSelector:")
ulpgr.minimumPressDuration = 2.0
routeMapView.addGestureRecognizer(ulpgr)
}
Any help?
Upvotes: 1
Views: 236
Reputation: 1038
I tried your code and it seem to be working fine. "double taps" is printed. Here's the test code.
import UIKit
import MapKit
class ViewController: UIViewController, CLLocationManagerDelegate {
let manager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation()
let routeMapView = MKMapView()
self.view = routeMapView
routeMapView.zoomEnabled = false
routeMapView.showsPointsOfInterest = true
let doubleTapGesture = UITapGestureRecognizer(target: self, action: "routeMapDoubleTapSelector:")
doubleTapGesture.numberOfTapsRequired = 2
routeMapView.addGestureRecognizer(doubleTapGesture)
let ulpgr = UILongPressGestureRecognizer(target: self, action:"routeMapLongPressSelector:")
ulpgr.minimumPressDuration = 2.0
routeMapView.addGestureRecognizer(ulpgr)
}
func routeMapDoubleTapSelector(sender: AnyObject) {
NSLog("double taps")
}
func routeMapLongPressSelector(sender: AnyObject) {
NSLog("long press")
}
}
Upvotes: 1