Я пытаюсь продублировать то, что указано в ссылке. Я пытаюсь отобразить Tableview с изображениями, которые могут быть проверены для приложения IOS. Я не совсем уверен, что я делаю не так, чтобы не показывать изображения. Я удостоверился, что добавил изображения в папку ресурсов и правильно назвал их в своем файле ViewController. Вот код для моего файла:
import UIKit
class CustomCell : UITableViewCell{
@IBOutlet var myImage: UIImageView!
@IBOutlet var myText: UILabel!
}
class RmMatchingViewControllor : UIViewController, UITableViewDelegate, UITableViewDataSource{ //
@IBOutlet var tableView: UITableView!
var labelData = ["Social Drinking", "Clean Freak", " Do you Cook", "Enjoy Movies", "Listen to Music", "Enjoy Sports","Perefer temperature cold", "Non smoking"]
var imageData = ["Beer", "Clean", "cooking", "movies", "Music","NFL","roomTemp", "Smoking"]
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
tableView.tableFooterView = UIView()
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
let cell:CustomCell = self.tableView.dequeueReusableCell(withIdentifier: "customCell") as! CustomCell //check this spot if program doesnt run
cell.myText?.text = self.labelData[indexPath.row]
cell.myImage?.image = UIImage(named:self.imageData[indexPath.row])
return cell
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return labelData.count
}
func numberOfSections(in tableView: UITableView) -> Int{
return 1
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
if let cell = tableView.cellForRow(at: indexPath as IndexPath){
if cell.accessoryType == .checkmark{
cell.accessoryType = .none
} else{
cell.accessoryType = .checkmark
}
}
}
}
![Here is the picture of the ViewControllor](https://i.stack.imgur.com/W9WTS.png)
введите описание изображения здесь
введите описание изображения здесь