iOS Cocoa pod Eureka:如何添加 CheckRow 列表和按钮

iOS Cocoa pod Eureka: How to add an CheckRow list and a button

我想创建一个视图,其中包含带有选项列表的部分和带有 "go next button"

的另一行

但是Eureka GitHub中的示例代码并没有告诉你怎么做。那是因为示例是一个空页面,只有复选框行,没有其他内容。当尝试在该视图的另一部分放置一个按钮时,出现以下错误:

+++ is not a prefix unary operator

我的例子class是:

import UIKit
import Eureka

class PaymentView: FormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        setForm()
    }

    func onNext() {
        print("go to review!")
    }

    func setForm() {
        form

        +++ SelectableSection<ListCheckRow<String>>("Elige la forma de pago:", selectionType: .singleSelection(enableDeselection: true))

        let paymentMethods = ["Dinero en efectivo", "Datafast"]
        for option in paymentMethods {
            (self.form.last!) <<< ListCheckRow<String>(option){ listRow in
                listRow.title = option
                listRow.selectableValue = option
                listRow.value = nil
            }
        }

        +++ Section("Footer")
            <<< ButtonRow(){
                [=12=].title = "Elegir método de pago"
                }
                .onCellSelection { [weak self] (cell, row) in
                    if row.section?.form?.validate().count == 0{
                        self?.onNext()
                    }
                    else {
                        print("The form has errors")
                    }

                    // End form
        }
    }
}

以防其他人遇到同样的问题。解决方案是这样的: 在追加一个新的部分或 table 行项目之前使用 (self.form) 来继续 Eureka 表单生成器的链。它看起来像这样:

(self.form) +++ Section("button")
// rest of your code