错误来自 let cell = self.tableView.dequeueReusableCellWithIdentifier("todoCell") as! UITableViewCell
我该如何处理这个问题,为什么会出现问题?
class ViewController: UIViewController , UITableViewDataSource {
@IBOutlet weak var tableView: UITableViewCell!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return 20
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("todoCell") as! UITableViewCell
return cell
}
}
最佳答案
您的 tableView
socket 被错误地声明为 UITableViewCell
而不是 UITableView
。
@IBOutlet weak var tableView: UITableView!
顺便说一句 - 在各种数据源和委托(delegate)方法中,使用 tableView
参数而不是访问属性。
例子:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("todoCell") as! UITableViewCell
return cell
}
关于ios - UITableViewCell' 没有成员 'dequeueReusableCellWithIdentifier',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34689502/