所以我有这个表单,它推送一个用于收集邮寄地址信息的子表单(为了清楚起见,我在此处简化了表单的 JSON 定义 - 我确实测试了这个版本,但它仍然中断):
{
"grouped": true,
"title": "Add",
"sections": [
{ "elements":[
{ "type":"QLabelElement", "title":"Location",
"sections": [
{
"elements": [ { "type":"QEntryElement", "title":"Address line 1","placeholder":"", "bind":"textValue:Address1", "key":"Address1"},
{ "type":"QEntryElement", "title":"Address line 2","placeholder":"optional", "bind":"textValue:Address2", "key":"Address2"},
{ "type":"QEntryElement", "title":"City","placeholder":"", "bind":"textValue:City", "key":"City"},
{ "type":"QEntryElement", "title":"State/Province","placeholder":"", "bind":"textValue:StateProvRegion", "key":"Prov"},
{ "type":"QEntryElement", "title":"ZIP/Postal Code","placeholder":"", "bind":"textValue:PostalCode", "key":"PCode"},
{ "type":"QPickerElement", "title":"Country", "items":[["Czech Republic", "Germany", "United Kingdom"]], "value":"Czech Republic"}
]
}]
}
]
}
]
}
我有一个 NSMutableDictionary ,其中包含一堆数据,可以预先弹出表单中的所有字段,包括地址中的字段。填充字典并显示对话框的代码如下所示(再次,超级简化,但这仍然中断):
NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];
[dataDict setObject:@"123 Maple Street" forKey:@"Address1"];
QRootElement *root = [[QRootElement alloc] initWithJSONFile:@"addjobform" andData:dataDict];
UINavigationController *navigation = [QuickDialogController controllerWithNavigationForRoot:root];
[self presentModalViewController:navigation animated:YES];
如果我使用上面的 JSON 运行此代码,对话框会正常显示,但不会填充字段。但是 -如果我将地址元素从嵌套子表单中移回第一级- 它们会填充(在这种情况下,Address1 会预先弹出 123 Maple Street)。换句话说,这个 JSON 正确绑定,而上面的先前版本没有:
{
"grouped": true,
"title": "Add",
"sections": [{
"elements": [ { "type":"QEntryElement", "title":"Address line 1","placeholder":"", "bind":"textValue:Address1", "key":"Address1"},
{ "type":"QEntryElement", "title":"Address line 2","placeholder":"optional", "bind":"textValue:Address2", "key":"Address2"},
{ "type":"QEntryElement", "title":"City","placeholder":"", "bind":"textValue:City", "key":"City"},
{ "type":"QEntryElement", "title":"State/Province","placeholder":"", "bind":"textValue:StateProvRegion", "key":"Prov"},
{ "type":"QEntryElement", "title":"ZIP/Postal Code","placeholder":"", "bind":"textValue:PostalCode", "key":"PCode"},
{ "type":"QPickerElement", "title":"Country", "items":[["Czech Republic", "Germany", "United Kingdom"]], "value":"Czech Republic"}
]
}
]
}
为什么绑定在第一级起作用,而不是嵌套在 Location 标签下?表单推送按广告宣传,但绑定已损坏 - 我有什么特别的事情要做吗?我进行了广泛搜索,但没有找到答案或示例。我在一个精简的单视图应用程序中尝试了此代码,该应用程序只执行上述操作,但它仍然中断 - 所以它也不是与我的其他代码的交互。根据 QuickDialog 的作者,应该支持子表单嵌套(https://github.com/escoz/QuickDialog/issues/226)有什么想法吗?谢谢!