我的代码中无法识别的选择器错误?

时间:2017-04-12 22:34:36

标签: swift

我有以下方法调用“updateMapView(sender:UIButton)”方法,但是我得到了无法识别的选择器错误。我已经设置了action:属性以及其他变体,例如updateMapView:sender和stuff,所以这不是问题。可能是什么呢?

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
}

1 个答案:

答案 0 :(得分:0)

重命名您的方法,使其看起来像func updateMapView(_ sender: UIButton)并使用#selector(updateMapView)作为您的操作。