我的代码中无法识别的选择器错误?
问题描述:
我有以下方法,将调用“updateMapView(sender:UIButton)”方法,但我得到无法识别的选择器错误。我已经设置了动作:属性与其他变化,如updateMapView:发件人和东西,所以这不是一个问题。可能是什么?我的代码中无法识别的选择器错误?
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: MapsTableViewCell.reuseIdentifier, for: indexPath) as? MapsTableViewCell else {
fatalError("Unexpected Index Path")
}
let map = fetchedResultsControllerForMapEntity.object(at: indexPath)
// Configure Cell
cell.mapNameLabel.text = map.name
cell.button.accessibilityHint = map.name
cell.button.addTarget(self, action: "updateMapView:", for: .touchUpInside)
return cell
}
答
重命名你的方法,所以它看起来像func updateMapView(_ sender: UIButton)
和使用#selector(updateMapView)
为你的行动。
将该方法重命名为'func updateMapView(_ sender:UIButton)' – Callam
阅读http://*.com/questions/24007650/selector-in-swift和接受的答案。 – rmaddy