2017-04-12 75 views
-3

我有以下方法,將調用「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 
} 
+0

將該方法重命名爲'func updateMapView(_ sender:UIButton)' – Callam

+0

閱讀http://stackoverflow.com/questions/24007650/selector-in-swift和接受的答案。 – rmaddy

回答

0

重命名你的方法,所以它看起來像func updateMapView(_ sender: UIButton)和使用#selector(updateMapView)爲你的行動。

相關問題