Sorry, I have a UIViewController as the superclass and the UICollectionView (not UICollectionViewController) as a subclass and a UITableView (not UITableViewController) as another subclass.
I have created the prototype cell in the UICollectionView with a UILabel inside. Custom class for UICollectionView is set to BtnCollectionView and the custom class for the Cell is set to BtnCollectionViewCell.
BtnCollectionViewCell.swift
import UIKit
class BtnCollectionViewCell: UICollectionViewCell {
@IBOutlect var btnLabel:UILabel!
}
BtnCollectionView.swift
import UIKit
private let reuseIdentifier = "Cell"
class BtnCollectionView: UICollectionView {
var BtnLabels = [...] // Array of 25 text strings
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return BtnLabels.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath)
// ERROR - "Value of type UICollectionViewCell has no member btnLabel"
cell.btnLabel.text = UILabel()
}
This is all basic code but the last line of code in the BtnCollectionView does not recognise the btnLabel. I'm not sure why? I do have another class of FirstViewController, this is the class for the superclass (UIViewController) in the storyboard. Does this make any more sense.