【问题标题】:Updating tableView code from Swift 1.2 - 2.0从 Swift 1.2 - 2.0 更新 tableView 代码
【发布时间】:2015-09-18 13:26:15
【问题描述】:

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

【问题讨论】:

    标签: xcode swift swift2 ios9


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-22
      • 1970-01-01
      相关资源
      最近更新 更多