'UIGestureRecognizer' 类型的值没有成员 'numberOfTapsRequired' 为什么会出现此错误?

Value of type 'UIGestureRecognizer' has no member 'numberOfTapsRequired' Why am I getting this error?

我收到此错误“'UIGestureRecognizer' 类型的值在我的代码中没有成员 'numberOfTapsRequired',因为我正在添加双击,我阅读了许多关于该主题的其他帖子,我可以找不到问题出在哪里。你能发现我在 addDoubleTap 函数中做错了什么吗?这是整个代码

import UIKit
import MapKit
import CoreLocation

class MapViewController: UIViewController, MKMapViewDelegate, UIGestureRecognizerDelegate {

    @IBOutlet weak var mapView: MKMapView!
    @IBOutlet weak var dropPinButton: UIButton!
    @IBOutlet weak var centerMApButton: UIButton!

    var pin: AnnotationPinn!
    // variables that hold values for selected icon, to be used for displaying the pin
    var dataReceived: String? 

    // udemy location manager couse
    var locationManager = CLLocationManager()
    let authorizationStatus = CLLocationManager.authorizationStatus()
    let regionRadius: Double = 1000.0



    override func viewDidLoad() {
        super.viewDidLoad()
        mapView.delegate = self
        locationManager.delegate = self

        configureLocationServices()
        setCoordinates()
//        addDoubleTap()
        let latitude: Double = setCoordinates().lat    //44.498955
        let longitude: Double = setCoordinates().lon   //11.327591
        let title: String? = dataReceived
        var subtitle: String? = dataReceived

        let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
        let region = MKCoordinateRegionMakeWithDistance(coordinate, 1000, 1000)
        mapView.setRegion(region, animated: true)

        // title may be to be taken from iconNames[indexpath.row]
        pin = AnnotationPinn(title: "", subtitle: "", coordinate: coordinate)
    }

    func addDoubleTap() { //not finding numberOfTapsRequired
        let doubleTap = UIGestureRecognizer(target: self, action: #selector(MapViewController.dropPin))
        doubleTap.numberOfTapsRequired = 2
        doubleTap.delegate = self
        mapView.addGestureRecognizer(doubleTap)
    }

    func centerMapOnLocation() {
        guard let coordinate2 = locationManager.location?.coordinate else {
            return
        }
        let coordinateRegion = MKCoordinateRegionMakeWithDistance(coordinate2, regionRadius * 2.0, regionRadius * 2.0)
        mapView.setRegion(coordinateRegion, animated: true)

    }





    //custom pin image , named: iconsImages[indexPath.row]
    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
        let annotationView = MKAnnotationView(annotation: pin, reuseIdentifier: "strada chiusa")

        //added if statement for displaying user location blue dot
        if annotation is MKUserLocation{
            return nil
        } else {
        annotationView.image = UIImage(named: dataReceived!) // here choose the image to load

        let transform = CGAffineTransform(scaleX: 0.22, y: 0.22)
        annotationView.transform = transform
        return annotationView
        }
    }

    // get coordinates into variables for the dropPin()
    func setCoordinates() -> ( lat: Double, lon:Double) {
    let location = locationManager.location?.coordinate
    let lat:Double = (location?.latitude)!
    let lon:Double = (location?.longitude)!
     print(lat,lon)
     return (lat, lon)
    }

   func dropPin() {




//           print("3\(String(describing: dataReceived))")
        mapView.addAnnotation(pin)


    }

    @IBAction func dropPinButton(_ sender: Any) {
        performSegue(withIdentifier: "chooseIconSegue", sender: self)
    }

    @IBAction func centerMapButton(_ sender: Any) {
        if authorizationStatus == .authorizedAlways || authorizationStatus == .authorizedWhenInUse{
            centerMapOnLocation()
        }
    }

    @IBAction func unwindHere(sender:UIStoryboardSegue) { // datas coming back

        if let sourceViewController = sender.source as? IconsViewController {
//            MyVariables.dataReceived = sourceViewController.dataPassed
            dataReceived = sourceViewController.dataPassed
//            title = sourceViewController.dataPassed

            print(dataReceived!)
            dropPin()
            mapView.addAnnotation(pin)
        }
    }


    func configureLocationServices() {
        if authorizationStatus == .notDetermined{
            locationManager.requestAlwaysAuthorization()
        } else {
            return
        }
    }

    func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
        centerMapOnLocation()
        }
    }

extension MapViewController: CLLocationManagerDelegate{
    }

UIGestureRecognizer 没有一个名为 numberOfTapsRequired 的 属性,这就是您遇到编译错误的原因。

你要找的是UITapGestureRecognizer