我正在使用Xcode 8和swift 3.我在行"let action"上有以下错误: #selector'指的是没有暴露给Objective-C的方法有什么 建议吗?
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)
}
}
Run Code Online (Sandbox Code Playgroud)
尝试将NSObject继承到您的类.
class YourClass {
...
}
Run Code Online (Sandbox Code Playgroud)
至
class YourClass: NSObject {
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4447 次 |
| 最近记录: |