为什么不能删除Eureka演示中的行?

时间:2018-02-21 22:21:42

标签: ios eureka-forms

我尝试从Eureka演示中学到一些东西,但是当我进入Eureka Demo App:

多值部分 - >选择任何行(例如:多值仅删除):

how can I delete any row???

我无法点击左删除按钮删除任何行,为什么?

源代码在这里:

class MultivaluedOnlyDeleteController: FormViewController {

  @IBOutlet weak var editButton: UIBarButtonItem!

  override func rowsHaveBeenRemoved(_ rows: [BaseRow], at indexes: [IndexPath]) {
      print("delete row")
  }

  override func viewDidLoad() {
      super.viewDidLoad()
      tableView.isEditing = false
      let nameList = ["family", "male", "female", "client"]

      let section = MultivaluedSection(multivaluedOptions: .Delete, footer: "you can swipe to delete when table.isEditing = false (Not Editing)")


      for tag in nameList {
          section <<< TextRow {
                          $0.placeholder = "Tag Name"
                          $0.value = tag
                      }
      }


      let section2 =  MultivaluedSection(multivaluedOptions: .Delete, footer: "")
      for _ in 1..<4 {
          section2 <<< PickerInlineRow<String> {
                          $0.title = "Tap to select"
                          $0.value = "client"
                          $0.options = nameList
                       }
      }

      editButton.title = tableView.isEditing ? "Done" : "Edit"
      editButton.target = self
      editButton.action = #selector(editPressed(sender:))

      form    +++

              section

              +++

              section2
  }

  @objc func editPressed(sender: UIBarButtonItem){
      tableView.setEditing(!tableView.isEditing, animated: true)
      editButton.title = tableView.isEditing ? "Done" : "Edit"

  }
}

我不知道如果我错过了什么?

感谢

1 个答案:

答案 0 :(得分:3)

演示中的问题是他们在单元格中缺少添加操作

CurrentCode代码

    for tag in nameList {
        section <<< TextRow {
                        $0.placeholder = "Tag Name"
                        $0.value = tag

                    }
    }

固定代码

    for tag in nameList {
        section <<< TextRow {
                        $0.placeholder = "Tag Name"
                        $0.value = tag

                        let deleteAction = SwipeAction(style: .destructive, title: "Delete") { (action, row, completionHandler) in
                            print("Delete")
                            completionHandler?(true)
                        }

                        $0.trailingSwipe.actions = [deleteAction]
                    }
    }

在我的前叉https://github.com/rmelian2014/Eureka

上修复了gihub中的问题演示代码