将多个参数传递给UIButton for Swift3中的选择器函数

时间:2017-07-24 06:52:40

标签: ios swift3 uibutton xcode8

我正在尝试将多个参数传递给swift3代码中的UIButton选择器,如下所示:

    func openMaps(longitude: CGFloat, latitiude: CGFloat) {
    let googleMapsInstalled = UIApplication.shared.canOpenURL(URL(string: "comgooglemaps://")!)
    var latitude = 29.2746
    var longitude = 47.8433
    if googleMapsInstalled {
      if #available(iOS 10.0, *) {
        UIApplication.shared.open(URL(string: "comgooglemaps-x-callback://" +
          "?daddr=\(latitude),\(longitude)&directionsmode=bicycling&zoom=17")!)
      } else {
      }
    } else {
        Utility.showAlert(title: Constants.error, message: Constants.someThingWrong, delegate: self)
    }
  }

为了调用这个函数,我正在使用uibutton选择器,如下所示:

cell.viewInMap.addTarget(self, action: #selector(openMaps(longitude:shop.longitude!,latitiude:shop.latitude!)), for: .touchUpInside)

但是我收到以下错误: enter image description here

如何将多个参数传递给UIButton选择器?我哪里错了?

0 个答案:

没有答案