我需要創建一個關於JSON數據值的動態表單。我已經解析了JSON數據,並獲得了不同控件(如Textfield,TextView,下拉列表和開關)的數據,但不知道如何在窗體視圖中動態添加字段。任何幫助將非常感激。謝謝!在iOS中使用JSON數據創建動態表單Objective-C
{
"success": true,
"result": {
"label": "Contacts",
"name": "Contacts",
"createable": true,
"updateable": true,
"deleteable": true,
"retrieveable": true,
"fields": [
{
"name": "salutationtype",
"label": "Salutation",
"mandatory": false,
"type": {
"name": "string"
},
"nullable": true,
"editable": true,
"default": ""
},
{
"name": "firstname",
"label": "First Name",
"mandatory": false,
"type": {
"name": "string"
},
"nullable": true,
"editable": true,
"default": ""
},
{
"name": "contact_no",
"label": "Contact Id",
"mandatory": false,
"type": {
"name": "string"
},
"nullable": false,
"editable": false,
"default": ""
},
{
"name": "phone",
"label": "Office Phone",
"mandatory": false,
"type": {
"name": "phone"
},
"nullable": true,
"editable": true,
"default": ""
},
{
"name": "lastname",
"label": "Last Name",
"mandatory": true,
"type": {
"name": "string"
},
"nullable": false,
"editable": true,
"default": ""
},
{
"name": "mobile",
"label": "Mobile Phone",
"mandatory": false,
"type": {
"name": "phone"
},
"nullable": true,
"editable": true,
"default": ""
},
{
"name": "account_id",
"label": "Organization Name",
"mandatory": false,
"type": {
"refersTo": [
"Accounts"
],
"name": "reference"
},
"nullable": true,
"editable": true,
"default": ""
},
{
"name": "leadsource",
"label": "Lead Source",
"mandatory": false,
"type": {
"picklistValues": [
{
"label": "Cold Call",
"value": "Cold Call"
},
{
"label": "Existing Customer",
"value": "Existing Customer"
},
{
"label": "Self Generated",
"value": "Self Generated"
},
{
"label": "Employee",
"value": "Employee"
},
{
"label": "Partner",
"value": "Partner"
},
{
"label": "Public Relationship",
"value": "Public Relationship"
},
{
"label": "Direct Mail",
"value": "Direct Mail"
},
{
"label": "Conference",
"value": "Conference"
},
{
"label": "Trade Show",
"value": "Trade Show"
},
{
"label": "Website",
"value": "Website"
},
{
"label": "Word of Mouth",
"value": "Word of Mouth"
},
{
"label": "Others",
"value": "Others"
}
],
"defaultValue": "Cold Call",
"name": "picklist"
},
"nullable": true,
"editable": true,
"default": ""
},
。 – Mukesh
我設計了窗體,但是有問題從所有字段獲取數據。 任何幫助將不勝感激。 – Mukesh
我想你的意思是獲取用戶輸入的數據?在那種情況下,你如何*想要*檢索數據?有很多可能性,所以第一步是瞭解用戶輸入數據後要處理的數據。一旦你知道了,你可以(例如)創建一個字典,在你創建它時存儲每個字段。從那裏你可以在用戶完成後再次訪問它。 – LGP