我不理解为什么我的应用程序不编译。这是目前的输出:与“类型'ViewController'相关的编译和生成错误不符合协议'UITableViewDataSource'”
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var IndexArray = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
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 numberOfSectionsinTableView(tableView: UITableView) -> Int {
return IndexArray.count
}
func tableView(tableView: UITableView, tiltleForHeaderInSection section: Int) -> String? {
return IndexArray[section]
}
func sectionIndexTitlesfortableView (tableView: UITableView) -> [String]? {
return IndexArray
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TableCell", for: indexPath as IndexPath) as! TableCell
cell.imgPhoto.image = UIImage(named: "charity")
cell.lblUserName.text! = "User Name"
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
}
}
您所有的实现代码如下方法有拼写错误/ miscapitalized单词或正在使用的是快速的3种不同的SWIFT 2个方法签名。使用Xcode的自动完成来获得正确的签名。 – dan
你在谈什么Swift版本?该代码是一个Swift 2/3混合调整器。 – vadian
我相信我正在使用Swift版本3.我不确定如何确定Swift版本。 –