Search code examples
iosswiftuitableviewcell

I do not understand why my cell is not showing up?


I do not understand why my cell is not showing up even though I have the correct identifier and class

class homeViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {





override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    
}

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    print("p")
    let cell: homeTableViewCell = tableView.dequeueReusableCell(withIdentifier: "homeTableViewCell", for: indexPath) as! homeTableViewCell
    
    return cell
} 

}

The identifier is the same in both table view cell and here


Solution

  • Please set delegate and dataSource for your tableview.

    For ex:

    this.tableView.delegate = self
    this.tableView.dataSource = self