2
- 最初のイメージ私は
MYサブアイテムがのUITableViewCellは空であるとき、テーブルビューのスクロール逆さま
- 第二の画像とき、私は表示されているのtableViewをスクロールしていないときスクロールテーブルビュー
MYサブアイテムがマイCellFor行のコードは、データソースを構築しながら、行のために細胞内ループのために避けるようにしてください
var aryDictData = [[String:AnyObject]]()
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var aryOptionName = [String]()
var strOptionName = String()
var cell = DeliveryTableViewCell()
cell = tableView.dequeueReusableCell(withIdentifier: "DeliveryTableViewCell") as! DeliveryTableViewCell
cell.selectionStyle = .none
let productPrice = userDefault.object(forKey: ProductDesConstantNames.KAryStorePrices) as! [String]
if indexPath.section == 0{
if indexPath.row < (aryDictData[0]["storeName"]!).count{
cell.lblItemName.text = ((aryDictData[0]["storeName"]! as AnyObject)[indexPath.row] as! String)
cell.lblPrice.text = "$\(String(((Double(productPrice[indexPath.row])! + grandTotalProductPrice[indexPath.row]) * Double(numQuntity))))"
cell.lblItemQuantity.text = "\(numQuntity)x"
cell.lblItemQuantity.textColor = UIColor.init(red: 41/255, green: 144/255, blue: 85/255, alpha: 1.0)
let data = aryPreviewOrder[indexPath.row] as! [[String:AnyObject]]
print(data)
for i in 0..<((aryDictData[0]["options"]! as AnyObject)[indexPath.row]! as AnyObject).count {
let optionName = ((((aryDictData[0]["options"]! as AnyObject)[indexPath.row]! as AnyObject)[i] as AnyObject)["option_name"] as! String)
let prices = ((((aryDictData[0]["options"]! as AnyObject)[indexPath.row]! as AnyObject)[i] as AnyObject)["price"] as! String)
aryOptionName.append("\(optionName) ($\(prices))")
// aryOptionPrices.append("($\(prices))")
strOptionName = aryOptionName.joined(separator: "\n")
// strOptionPrice = aryOptionPrices.joined(separator: "\n")
}
cell.lblOptionNames.text = strOptionName
}
}
}
return cell
}
あなたがstrOptionName'毎回 '内のデータを取得していることを確認している私は、迅速な3 – KavyaKavita
あなたcellforrowにコードを追加してください?、cell.lblOptionNames.text = strOptionName後cell.layoutIfNeededを()、書き込みその行の前に – Prototype
に取り組んでいます –