我在 Swift 3 项目中使用 Eureka Form-Framework。
我需要使用 MultivaluedSection,但不是从字符串选项数组中获取字符串(如下面的代码),我想在呈现的 Controller 中打开一个子表单(例如,使用 TextRow、NumberRow 等)。
我知道,我可以实现自定义演示者行,但我找不到为自定义演示者行显示“子表单”的解决方案。
Eureka 框架甚至可以做到这一点吗?
let multivaluedSection = MultivaluedSection(multivaluedOptions: [.Insert, .Delete],
header: rawField["name"].stringValue,
footer: "")
multivaluedSection.multivaluedRowToInsertAt = { index in
return PushRow<String>{
$0.title = "Tap to select ;)..at \(index)"
$0.options = ["Option 1", "Option 2", "Option 3"]
} }
self.form.append(multivaluedSection)
最佳答案
这可以使用自定义选择器行来完成。
您只需要按照说明进行操作here , 制作自定义推行,
public final class CustomPushRow: SelectorRow<PushSelectorCell<SomeType>, YourSubFormVC>, RowType {
public required init(tag: String?) {
super.init(tag: tag)
presentationMode = .show(controllerProvider: ControllerProvider.callback {
return YourSubFormVC(){ _ in }
}, onDismiss: { vc in
_ = vc.navigationController?.popViewController(animated: true)
})
}
}
YourSubFormVC
是用户点击该行时将显示的 VC。它应该符合 TypedRowControllerType
。因为你希望这个 VC 也是一个表单,所以让它继承 FormViewController
并开始在 viewDidLoad
中构建表单!
关于swift - Swift Eureka 中的子表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47269180/