Trying to use a custom cell which a label and two buttons. I managed to create a subclass for custom cell and I need to show them in the cell as well. This is my code:
import UIKit
import Alamofire
import SwiftyJSON
class TableViewController: UITableViewController {
@IBOutlet var table: UITableView!
var fruits = ["Orange", "Apple", "Banana"]
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
tableView.rowHeight = 80
self.tableView.register(tableDetailsVCTableViewCell.self, forCellReuseIdentifier: "cell")
}
@objc func downloadPressed() {
print("Download Button Presses")
}
@objc func previewPressed() {
print("Preview Button Pressed")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
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: "cell", for: indexPath) as! tableDetailsVCTableViewCell
cell.lable?.text = fruits[indexPath.row]
cell.dlB?.addTarget(self, action: #selector(downloadPressed), for: .touchUpInside)
cell.pvB?.addTarget(self, action: #selector(previewPressed), for: .touchUpInside)
return cell
}
}
I run the app but nothing shows up. No text in the label nor any buttons
self.tableView.register(tableDetailsVCTableViewCell.self, forCellReuseIdentifier: "cell")