0
我創建了一個自定義的UICollectionViewCell,我試圖從UICollectionView
delegate
方法cellForItemAtIndexPath
引用,而且我不斷收到Cannot assign value of type 'UICollectionViewCell' to type 'GridViewCell'
UICollectionViewCell不能將值分配給CustomCollectionViewCell
委託方法
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let asset = self.assetsFetchResults[indexPath.item] as! PHAsset
var cell = GridViewCell()
//Deque an GridViewCell
cell = collectionView.dequeueReusableCellWithReuseIdentifier(CellReuseIdentifier, forIndexPath: indexPath)
cell.representedAssetIdentifier = asset.localIdentifier
return cell
}
GridViewCell類
import UIKit
class GridViewCell: UICollectionViewCell {
@IBOutlet weak var imageView: UIImageView!
var thumbnailImage = UIImage()
var representedAssetIdentifier = NSString()
override func prepareForReuse() {
super.prepareForReuse()
self.imageView.image = nil
}
//func setThumbnailImage(thumbnailImage: UIImage) {
// self.imageView.image = thumbnailImage
//}
}
你分配GridViewCell類故事板細胞的身份檢查? –
我已經做到了。並重新檢查,如果我一次又一次 –
var cell:CustomTableViewCell? = tableView.dequeueReusableCellWithIdentifier(「mycell」)爲? CustomTableViewCell 如果細胞==零{ 電池= CustomTableViewCell(風格:UITableViewCellStyle.Subtitle,reuseIdentifier: 「了myCell」) } –