#selector' 指的是没有暴露给 Objective-C swift 3 的方法 [英] #selector' refers to a method that is not exposed to Objective-C swift 3

查看:30
本文介绍了#selector' 指的是没有暴露给 Objective-C swift 3 的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Xcode 8 和 swift 3.我在让操作"行中出现以下错误:#selector' 指的是没有暴露给 Objective-C 的方法有什么建议吗?

I'm using Xcode 8 and swift 3. I have the following error on line "let action": #selector' refers to a method that is not exposed to Objective-C Any suggestion ?

   override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cellWaze", for: indexPath) as! WazeTableViewCell

    // Configure the cell...
    cell.lbAgence.text = aWAgence[indexPath.row][0] as? String
    let cellLat :Double = aWAgence[indexPath.row][1] as! Double
    let cellLong :Double = aWAgence[indexPath.row][2] as! Double

    cell.bWaze.tag = indexPath.row
    let action = #selector(LaunchWaze(cellLat,longitude: cellLong))
    cell.bWaze.addTarget(self, action: action, for: .touchUpInside)

    return cell
}

@objc func LaunchWaze(_ latitude: Double, longitude: Double) {
    if UIApplication.shared.canOpenURL(NSURL(string: "waze://")! as URL) {
        // Waze is installed. Launch Waze and start navigation
        var urlStr = "waze://?ll=\(latitude),\(longitude)&navigate=yes"
        print("url : \(urlStr)")
        //UIApplication.shared.openURL(NSURL(string: urlStr)!)
    }
    else {
        // Waze is not installed. Launch AppStore to install Waze app
        UIApplication.shared.openURL(NSURL(string: "http://itunes.apple.com/us/app/id323229106")! as URL)
    }
}

推荐答案

尝试将 NSObject 继承到您的类.

Try to inherit NSObject to your class.

class YourClass {
  ...
}

class YourClass: NSObject {
  ...
}

这篇关于#selector' 指的是没有暴露给 Objective-C swift 3 的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆