我一直收到错误:
无法转换类型的值'(UITableViewRowAction!,NSIndexPath!) - > Void'到期望的参数类型'(UITableViewRowAction,IndexPath) - > 无效“
有谁知道我能做些什么来摆脱这个错误?
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
var shareAction = UITableViewRowAction(style: .normal, title: "Share") {
(action:UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in
let firstActivityItem = self.animals[indexPath.row]
let activityViewController = UIActivityViewController(activityItems: [firstActivityItem], applicationActivities: nil)
self.presentviewcontroller(activityViewController, animated: true, completion: nil)
}
shareAction.backgroundColor = UIColor.blueColor()
return [shareAction]
}
答案 0 :(得分:0)
替换
(action:UITableViewRowAction!, indexPath: NSIndexPath!)
与
(action:UITableViewRowAction, indexPath: IndexPath)
或者,甚至更好,只是
(action, indexPath)