我認爲這是很容易只是創建自定義單元格類來實現這一目標
第1步:創建JSON響應的陣列
說arrayForPrice它包含所有的價格在給定的JSON
第2步:創建自定義類tableViewCell
class InputDataCell: UITableViewCell
{
@IBOutlet weak var txtItemPrice: UITextField!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
STEP:3分配價格從陣列uitextFieald在cellForRowMethod 像
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let inputDataCell:InputDataCell = (tableView.dequeueReusableCell(withIdentifier: "inputItemCell", for: indexPath) as? InputDataCell)! //InputDataCell is the Custom class For uitableViewCell
inputDataCell.txtItemPrice.text = arrayForPrice[indexPath.row]
return inputDataCell
}
可以使用的tableView – Jaydeep
在創建自定義單元格的UITableView –
for循環,不斷添加文本框,該文本框頂部將永遠被計算爲我*(一些常數),並保持該標籤爲我 – YaBoiSandeep