私はtableViewにセルを追加しました。どのセルにも画像を表示したい私のクラス "MathViewController"に画像の配列を追加して、これらの画像をcell.butで表示しません。私の問題について知っている人はいませんか?私はあなたが私を助ければすばらしいだろう、私は非常に迅速です。 その私のクラスMathTableViewCellはストーリーボードから画像を取得する:TableViewCellはimageViewを表示しません
import UIKit
class MathTableViewCell: UITableViewCell{
@IBOutlet weak var imageCell: UIImageView!
}
、ここでは、クラスMathViewControllerです: :あなたはセル識別子がMathTableViewCellに設定されているよう
import UIKit
class MathViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableController: UITableView!
let items = ["Calculatorimg" , "ss"]
override func viewDidLoad() {
super.viewDidLoad()
self.tableController.register(UITableViewCell.self, forCellReuseIdentifier: "MathTableViewCell")
tableController.rowHeight = UITableViewAutomaticDimension
tableController.estimatedRowHeight = 44
tableController.delegate = self
tableController.dataSource = self
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let cell = tableView.dequeueReusableCell(withIdentifier: "MathTableViewCell", for: indexPath) as? MathTableViewCell{
cell.imageCell.image = UIImage(named: items[indexPath.row])
return cell
}
return UITableViewCell()
}
}
、ここでは私のストーリーボードですstoryboard
これらの画像はアセットまたはフォルダ内にあります。これらの画像がフォルダ内にある場合、その画像の拡張子を "ss.png"のように指定する必要があります –
@jitendraModi彼らはアセットにあります – nino
項目[indexPath.row]を出力し、出力をチェックします。 –