动态生成 Eureka 表单行

Dynamically generate Eureka Form Rows

有没有办法从 json/api 响应构建尤里卡表单。到目前为止,我已经能够转换为 json 返回到一个对象。但是在创建 for 循环以生成表单时遇到问题。

form
+++ Section("API Returns")

for values in JSONObject{

    <<< TextRow() {
        [=10=].tag = values.key
        [=10=].title = values.name
        [=10=].value = values.value
    }
}

您需要指明 TextRow 将被插入循环中的哪个部分。

let section = Section("API Returns")
form +++ section

for values in JSONObject{

    section <<< TextRow() {
        [=10=].tag = values.key
        [=10=].title = values.name
        [=10=].value = values.value
    }
}

假设您的 "API Returns" 部分是表单的最后一部分,您也可以使用它。

for values in JSONObject {

    guard let section = self.form.last else {
        return
    }

    section <<< TextRow() {
        [=11=].tag = values.key
        [=11=].title = values.name
        [=11=].value = values.value
    }
}

你可以使用这个:

for values in JSONObject {

    guard let section = self.form.last else {
        return
    }

    section <<< TextRow() {
        [=10=].tag = values.key
        [=10=].title = values.name
        [=10=].value = values.value
    }
}
form
+++ section(){...}