xcode - 从 Swift 1.2 - 2.0 更新 tableView 代码

标签 xcode swift swift2 ios9

我写了这段代码来编辑行样式(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 的代码吗?

最佳答案

我认为您的代码属于 editActionsForRowAtIndexPatheditingStyleForRowAtIndexPath 需要返回行的编辑样式,例如 UITableViewCellEditingStyle.Delete。这是当您点击“编辑”按钮时显示的样式。

关于xcode - 从 Swift 1.2 - 2.0 更新 tableView 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32653229/

相关文章:

ios - SKSpriteNode 的缓出动画

ios - Swift 中枚举的默认值

ios - 将 CollectionView 或 ViewController 添加到 AlertView

objective-c - <CFData 0x100516c60 [0x7fff71adaea0]>{长度 = 6,容量 = 6,字节 = 0x0022412b03ad}

Swift 通过添加百分比创建字符串

ios - 使用 URL 在 Swift 中显示电话号码的所有系统选项

ios - 创建一个表示可以打开或关闭的可散列对象的协议(protocol)

ios - 我从 NSUserDefaults 得到的对象(字典)有问题

ios - iPhone 5/SE 显示白色状态栏,iPhone 6/7 显示黑色状态栏

ios - ITMS-90683 : Missing Purpose String in Info. plist NSCameraUsageDescription