我写了这段代码来编辑行样式(Swift 1.2 - Xcode 6.4)
func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle
{
let edit = UITableViewRowAction(style: .Normal, title: "Edit") { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in
let abb: AnyObject = self.frc.objectAtIndexPath(indexPath)
let editingView = self.storyboard?.instantiateViewControllerWithIdentifier("editingViewController") as! editingViewController
editingView.abbediting = abb
self.presentViewController(editingView, animated: true, completion: nil)
print("Edit Tapped")
print("Edited Button Clicked") }
edit.backgroundColor = UIColor.lightGrayColor()
let delete = UITableViewRowAction(style: .Normal, title: "Delete") { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in
let abbDel = self.frc.objectAtIndexPath(indexPath) as! NSManagedObject
self.con?.deleteObject(abbDel)
print("Delete Button Clicked")
}
delete.backgroundColor = UIColor.redColor()
return [delete,edit]
}
我还设置了一些操作,但在我更新到 Xcode 7.0 和 Swift 2.0 之后,我一直收到错误消息,提示我返回 UITableViewCellStyle。
任何人都可以帮助我将我的代码更新为适用于 Swift 2.0 的代码吗?
最佳答案
我认为您的代码属于 editActionsForRowAtIndexPath
。 editingStyleForRowAtIndexPath
需要返回行的编辑样式,例如 UITableViewCellEditingStyle.Delete
。这是当您点击“编辑”按钮时显示的样式。
关于xcode - 从 Swift 1.2 - 2.0 更新 tableView 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32653229/