ios 8.1: 类型 'ViewController' 不符合协议 'UICollectionViewDataSource'

ios 8.1: Type 'ViewController' does not conform to protocol 'UICollectionViewDataSource'

编译 swift 应用程序时出现以下错误 (iOS 8.1)

Type 'ViewController' does not conform to protocol 'UICollectionViewDataSource'

在“class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate”行

我刚刚在这里查看了几个帖子,但没有人帮助我解决这个问题。

这是 ViewController.swift 文件的代码:

import UIKit

class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
var tableDescription: [String] = []
var tableNumbers: [String] = []

override func viewDidLoad() {
    super.viewDidLoad()
    self.populateView()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func collectionView(collectionView: UICollectionView, numberOfItemInSection section: Int) -> Int{
    return tableDescription.count
}

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell{
    let cell: CollViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as CollViewCell
    
    cell.lblDescription.text = tableDescription[indexPath.row]
    cell.lblNumber.text = tableNumbers[indexPath.row]
    
    return cell
}

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
    println("Cell \(indexPath.row) selected")
}
 }

检查您的代码中是否有拼写错误,例如 - 使用 "numberOfItemsInSection" 代替 numberOfItemsInSection。