请帮我收集收藏中的自定义单元格
我有一个错误: ..这个类不是关键的cell_label编码兼容的值。 你可以在这里下载完整的项目: https://drive.google.com/file/d/0B1nXU0xmeKg8WTRYRXJVbWdMVlU/view?usp=sharing
我想在modalview中显示带有自定义单元格的集合
PS:我使用xcode 7 beta和swift 2并为每个视图分开xib
import UIKit
class ModalController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
@IBOutlet weak var myCollection: UICollectionView!
@IBOutlet weak var myCell: colywCell!
var tableData: [String] = ["XXX", "YYY", "ZZZ"]
override func viewDidLoad() {
super.viewDidLoad()
self.title="modal W"
myCollection.dataSource = self
myCollection.delegate = self
let nipName=UINib(nibName: "colywCell", bundle:nil)
myCollection.registerNib(nipName, forCellWithReuseIdentifier: "cell1")
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return tableData.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
self.myCell = myCollection.dequeueReusableCellWithReuseIdentifier("cell1", forIndexPath: indexPath) as! colywCell
self.myCell.Cell_label.text = tableData[indexPath.row]
return self.myCell
}
}
和自定义单元格文件
import UIKit
class colywCell: UICollectionViewCell {
@IBOutlet weak var Cell_label: UILabel!
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}