Criei um UICollectionViewCell personalizado no Interface Builder, vinculei visualizações à classe e, quando desejar usar e definir uma string para o rótulo da string, esse rótulo terá um valor nulo.
override func viewDidLoad() {
super.viewDidLoad()
// Register cell classes
self.collectionView.registerClass(LeftMenuCollectionViewCell.self, forCellWithReuseIdentifier: "ls")
}
override func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell! {
var cell: LeftMenuCollectionViewCell
cell = collectionView.dequeueReusableCellWithReuseIdentifier("ls", forIndexPath: indexPath) as LeftMenuCollectionViewCell
println(cell.label) // <- this is nil, why??
cell.label.text = "asd"
return cell
}
E a célula da subclasse:
class LeftMenuCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var label: UILabel!
@IBOutlet weak var activityIndicatorView: UIActivityIndicatorView!
}