Swift 的新手,这对我来说很适合 Objective-C。不确定这是语法问题还是我的项目设置不正确。
首先,这是我看到的错误(在 JobsViewController 的第 5 行,以 self.tableView.registerClass 开头的行):
无法使用类型为“(UITableViewCell.Type, forCellReuseIdentifier: String)”的参数列表调用“registerClass”
JobsViewController
class JobsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
return UITableViewCell()
}
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
}
}
Google 的帮助不是很大,希望能提供一些帮助!
最佳答案
在 Swift 3 中运行良好
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
关于ios - 无法在 Swift 中对 UITableView 调用 "registerClass",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30332859/