我在iOS中快速创建了动态html表,并且在创建行跨时感到困惑。由于我对HTML的了解较少,能否提供任何示例代码来动态行跨。
我已经基于表行标题创建了动态HTML表并动态显示数据。现在我想保留某些单元格的行跨度。但是对于保留html标签的位置感到困惑。
//Array for Column header
let tableColHeader = ["Breakfast","Lunch","Dinner","Bedtime"]
//Array for Column header
let tableRowHeader = ["Blood Sugar","Mealtime Insulin","Long-Acting Insulin","Carb Intake","Health Factors"]
//Array for TABLE DATA
let tableData =
[
[["114 mg/dL","114 mg/dL"],"114 mg/dL","Missed Entry","114 mg/dL"]
,[["2 units","2 units"],"2 units","2 units",""]
,["Long-Acting Insulin","","","10 units"]
,["Carb Intake","100 grams","100 grams","100 grams"]
,["Health Factors","","Activity, Stress",""]
]
//CODE:
let colCount : Int = (tableColHeader.count)-1
let rowCount : Int = (tableRowHeader.count)-1
for colIndex in 0...colCount {
//Setting column header
healthCareHtml.append("<th>")
healthCareHtml.append("\(tableColHeader[colIndex])")
healthCareHtml.append("</th>")
}
//iterating over table data based on row index
for rowIndex in 0...tableData.count - 1 {
//Setting data based on row header index and data
healthCareHtml.append("<tr align = 'left'>")
healthCareHtml.append("<th scope='row'>")
healthCareHtml.append((tableRowHeader[rowIndex])")
//iterating over table data based on row index
for dataIndex in 0...tableData[rowIndex].count -
{
// opening table data and displaying data into the table cell based on row index
healthCareHtml.append("<td>")
healthCareHtml.append("\(tableData[rowIndex][dataIndex])")
//closing table data
healthCareHtml.append("</td>")
}
//closing table header and table row
healthCareHtml.append("</th>")
healthCareHtml.append("</tr>")
}
}
预期的输出:我想为(0,0)血糖和(1,0)进餐时间胰岛素行创建行跨度。