use*_*930 2 uitableview ios swift
在我的应用程序中,我的类定义如下:
class MyTableViewController: UITableViewController {
Run Code Online (Sandbox Code Playgroud)
在里面我想添加刷选所选单元格的功能(取自这个答案)
但是当我在那里写这个:
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
let more = UITableViewRowAction(style: .Normal, title: "More") { action, index in
print("more button tapped")
}
more.backgroundColor = UIColor.lightGrayColor()
let favorite = UITableViewRowAction(style: .Normal, title: "Favorite") { action, index in
print("favorite button tapped")
}
favorite.backgroundColor = UIColor.orangeColor()
let share = UITableViewRowAction(style: .Normal, title: "Share") { action, index in
print("share button tapped")
}
share.backgroundColor = UIColor.blueColor()
return [share, favorite, more]
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:
使用Objective-C选择器的方法'tableView(:editActionsForRowAtIndexPath :)'tableView:editActionsForRowAtIndexPath:'与来自超类'UITableViewController'的方法'tableView(:editActionsForRowAtIndexPath :)'与同一个Objective-C选择器冲突
我试图添加,override但它没有帮助 - 是什么导致此错误,我该如何解决?
签名是略有不同:返回值应该是[UITableViewRowAction]?没有[AnyObject]?:
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]?
Run Code Online (Sandbox Code Playgroud)
你也需要它override.