我在斯威夫特的代码有一类设计UICollectionViewCells
斯威夫特:房产“self.tableView”在super.init调用未初始化
class PostCell: UICollectionViewCell, UITableViewDelegate, UITableViewDataSource {
let tableView: UITableView!
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .white
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellReuseIdentifier")
tableView.delegate = self
tableView.dataSource = self
designCell()
}
}
我需要在单元格中UITableView
因此,我加入UITableViewDelegate, UITableViewDataSource
类,但是这会返回以下错误
Property 'self.tableView' not initialized at super.init call
什么可能是问题,我该如何初始化tableView?
谢谢你,你回答之前初始化 – sakoaskoaso