我在斯威夫特的代碼有一類設計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