//
// ViewController.swift
// CollectionViewTry
//
// Created by Shivam Agrawal on 25/03/17.
// Copyright © 2017 Shivam Agrawal. All rights reserved.
//
import UIKit
class ViewController: UIViewController, UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 20, left: 10, bottom: 10, right: 10)
layout.itemSize = CGSize(width: 90, height: 120)
collectionView = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)
collectionView.dataSource = self
collectionView.delegate = self
collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "Cell")
collectionView.backgroundColor = UIColor.white
self.view.addSubview(collectionView)
/* print(BigBox.count)
for i in 0...80{
print("\(BigBox[i].identifier) \(BigBox[i].ColID) \(BigBox[i].RowID) \(BigBox[i].SmallBox) \(BigBox[i].sbCount)")
}*/
// 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 collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 14
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath as IndexPath)
cell.backgroundColor = UIColor.orange
return cell
}
ios 8.1: Type 'ViewController' does not conform to protocol 'UICollectionViewDataSource'即使我添加方法UICollectionViewDataSource它给了我一个错误
我的问题是一个上面相似的。我尝试和谷歌搜索,但无法找到如何解决我的代码中的错误。尽管我已经添加了方法,但它说不符合协议
谢谢。我是新来的迅速,因此我犯了愚蠢的错误,并试图学习。 – HellofromLearner