我在TableViewController中使用自定义TableViewCell。
即使数据正在填充,但我的TableViewCell也不会显示它。
这是我的自定义TableViewCell代码
class PlaceItemCellCustom: UITableViewCell {
@IBOutlet weak var placeFace: UILabel?
@IBOutlet weak var placeName: UILabel?
override func awakeFromNib() {
super.awakeFromNib()
}
}
这是我的TableViewOntoller
class PlaceListViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
loadListFromSource()
}
// Other code
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return places.count
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 100
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let place = places[indexPath.row]
// I am getting the data
print(place.placeName?.description ?? " " )
let customCell = tableView.dequeueReusableCell(withIdentifier: "PlaceListIdentifier", for: indexPath) as! PlaceItemCellCustom
customCell.placeName?.text = place.placeName
return customCell
}
}
我在这里错过了什么?我是IOS应用程序开发的新手。
发现类似
questions
但无济于事
编辑:默认的TableViewCell运行良好。
但是当我将其更改为自定义TableViewCell时,它不起作用。我也在故事板中设置了类名。
这是我的故事板
这是输出