Here is the code and here is my resulting display. I'm using a table view object, not a table view controller (table view controller works fine), because I intend to do something with the background. Idk why the sample text isn't displaying? This is probably really stupid... Here is the image of the output: !https://drive.google.com/file/d/1tEWZUjWP-8FhZKDvuAQyVV2vkh2_dyRL/view?usp=sharing And here is the image of how I configured the cells (I have another split view controller for another purpose, but never mind that since it's unrelated to problem): !https://drive.google.com/file/d/1u-T1J6xp1bZq12HRCSeD3Eq_VWlGH4lb/view?usp=sharing
Please help and thanks! I also tried to look at How to insert new cell into UITableView in Swift and used the +21 response
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
//MARK: Properties
@IBOutlet weak var drawingCanvas: UIView!
@IBOutlet weak var tableView: UITableView!
var tableData = ["one"]
//MARK: Table View
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if tableView == self.tableView {
let cell = tableView.dequeueReusableCell(withIdentifier: "TaskCell", for: indexPath)
// Configure the cell...
cell.textLabel?.text = tableData[indexPath.row]
return cell
}
return UITableViewCell()
}
}