简体   繁体   English

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

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

I'm getting the following error when compile swift application (iOS 8.1)编译 swift 应用程序(iOS 8.1)时出现以下错误

Type 'ViewController' does not conform to protocol 'UICollectionViewDataSource'类型“ViewController”不符合协议“UICollectionViewDataSource”

at "class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate" line在“class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate”行

I've just checked few posts here but no one helps me to solve this problem.我刚刚在这里查看了几篇帖子,但没有人帮我解决这个问题。

Here's the code of ViewController.swift file:这是 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”而不是 numberOfItemInSection。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型'ViewController'不符合协议'UICollectionViewDataSource' - Type 'ViewController' does not conform to protocol 'UICollectionViewDataSource' 类型“自定义TableViewController”不符合协议“ UICollectionViewDataSource” - Type 'Custom TableViewController' does not conform to protocol 'UICollectionViewDataSource' 类型“ ViewController”不符合协议 - Type 'ViewController' does not conform to protocol iOS - 错误类型'ViewController'不符合协议'UIPickerViewDataSource' - iOS - Error Type 'ViewController' does not conform to protocol 'UIPickerViewDataSource' Swift:类型'ViewController'不符合协议'UIPageViewControllerDataSource' - Swift: Type 'ViewController' does not conform to protocol 'UIPageViewControllerDataSource' 类型“ viewController”不符合协议“ PathMenuDelegate” - type “viewController” does not conform protocol “PathMenuDelegate” 类型的viewcontroller不符合协议uitableviewdatasource - type viewcontroller does not conform to protocol uitableviewdatasource 类型“ ViewController”不符合协议“ FBSDKLoginButtonDelegate” - The type 'ViewController' does not conform to protocol 'FBSDKLoginButtonDelegate' ViewController类型不符合协议SKPaymentTransactiionObserver - type ViewController does not conform to protocol SKPaymentTransactiionObserver 类型“ ViewController”不符合协议“ UITableViewDataSource” - Type “ViewController” does not conform to protocol 'UITableViewDataSource"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM