-4
我在Xcode8/Swift3中遇到问题。我在UIViewcontroller中有一个UITableView,我得到错误:Use of unresolved identifier 'cell'
。Swift 3错误:“使用未解析的标识符'单元格'”
的ViewContoller.swift
的代码是:
import UIKit
class WOWViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
var Hundenamen = ["Pete", "Washi", "WuffWuff", "Hundi", "TrallaBalla"]
var Hunderassen = ["Dackel", "Pudel", "Unbekannt", "Labrador", "Unbekannt"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
cell = self.tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! THISTableViewCell
cell.Hunderasse.text = Hunderassen[indexPath.row]
cell.Hundename.text = Hundenamen[indexPath.row]
return cell
}
}
而在这些线路:
cell = self.tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! THISTableViewCell
cell.Hunderasse.text = Hunderassen[indexPath.row]
cell.Hundename.text = Hundenamen[indexPath.row]
return cell
在Swift2它的工作,但最后函数的代码已经改变。
*在Swift2它的工作*。不,这个代码在Swift 2中也不起作用。 – vadian