Я пытаюсь зарегистрировать ячейку nib
в моем collectionView
, но он не будет отображаться.
Это мой MenuCardVC
import UIKit
class MenuCardVC: UIViewController{
@IBOutlet weak var collectionView: UICollectionView!
var drinksMenu = [Drink]()
var venueId: String?
//Selected venue
var venue: Venue? {
didSet{
loadDrinksMenu()
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView.delegate = self
self.collectionView.dataSource = self
let nib = UINib(nibName: "DrinkMenuCell", bundle: nil)
self.collectionView.register(nib, forCellWithReuseIdentifier: "DrinkMenuCell")
}//end viewDidLoad
func loadDrinksMenu(){
Utilities.run.showSVHUDWithStatus(uiView: self.view, status: "Loading menu")
getJWTfromGoogleCloudFunction()
}//end func
func getJWTfromGoogleCloudFunction(){
DoshiiServices.shared.getJWTfromGoogleCloudFunction { (token) in
self.drinksMenu.removeAll()
DoshiiServices.shared.getMenu(token: token, locationId: "xxxxxxx") { (bool, drinksMenu) in
self.drinksMenu = drinksMenu
Utilities.run.dismissSVHUD(delay: 0.2)
}//end getMenu
}//getJWTfromGoogleCloudFunction
}//end func
}//end class
extension MenuCardVC: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return drinksMenu.count
}//end func
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "DrinkMenuCell", for: indexPath) as! DrinkMenuCell
cell.configureCell(item: "BEER") //<---testing
return cell
}//end func
}//end extension
Это мой DrinkMenuCell
class DrinkMenuCell: UICollectionViewCell {
@IBOutlet weak var label: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
}
func configureCell(item: String){
self.label.text = item
}//end func
}
Я правильно установил свой идентификатор ячейки