對於Swift,我真的很陌生,問題是如何從標籤中的數組表示值。如何將數據從數組中放入標籤Swift 3
我想要一個帶有單元格的TableView動態地將數組中的值轉換爲將在tableView行中創建的標籤。
import UIKit
import Foundation
class TableViewMarketItemsViewCell: UITableViewController {
var fruits = ["Avocado", "Apricot", "Pomegranate", "Quince"]
var PriceArray = ["1000 тг.","4000 тг.","3000 тг.","2000 тг."]
var categoryArray = ["Green category","Maroon category","Red category","Yellow category"]
// MARK: - UITableViewDataSource
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return fruits.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "LabelCell", for: indexPath) as! TableViewCell
let fruitName = fruits[indexPath.row]
cell.productTitle.text = fruitName
cell.productImage.image = UIImage(named: fruitName)
return cell
}
}
日Thnx提前
https://www.weheartswift.com/how-to-make-a-simple-table-view-with-ios-8-and-swift/ –
你已經試過了什麼?你經歷了哪些教程,什麼不起作用,或者你不明白什麼?顯示一些代碼。 – Losiowaty