Home:ALL Converter>UICollectionView Cells not displaying

UICollectionView Cells not displaying

Ask Time:2016-12-05T16:37:42         Author:GHU

Json Formatter

In my UICollectionView the cells are not displayed. How can I fix this? Please help me.

The UICollectionView does not appear when you run the emulator

collectionViewController.swift

var dataset = [
    ("img1.jpeg", "img2.jpeg", "img3.jpeg", "AAA", "ENNNS", "14500", "29000", "50% SALE")
lazy var list : [listVO] = {
    var datalist = [listVO]()

    for (userIconImage, productImage, saleImage, userName, productName, saledPrice, price, perSale) in self.dataset {
        let listvo = listVO()

        listvo.userIconImage = userIconImage
        listvo.productImage = productImage
        listvo.saleImage = saleImage
        listvo.userName = userName
        listvo.productName = productName
        listvo.saledPrice = saledPrice
        listvo.price = price
        listvo.perSale = perSale

        datalist.append(listvo)

    }

    return datalist
}()

override func viewDidLoad() {
    super.viewDidLoad()

    self.collectionView!.register(uCollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)

    collectionView!.delegate = self
    collectionView!.dataSource = self
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

override func numberOfSections(in collectionView: UICollectionView) -> Int {
    return 1
}

override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return self.list.count
}

override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! uCollectionViewCell


    let row = self.list[indexPath.row]

    cell.userName?.text = row.userName
    cell.productName?.text = row.productName
    cell.saledPrice?.text = row.saledPrice
    cell.price?.text = row.price
    cell.perSale?.text = row.perSale

    return cell
}

collectionViewCell.swift

@IBOutlet weak var userIconImage: UIImageView!
@IBOutlet weak var productImage: UIImageView!
@IBOutlet weak var saleImage: UIImageView!
@IBOutlet weak var userName: UILabel!
@IBOutlet weak var productName: UILabel!
@IBOutlet weak var saledPrice: UILabel!
@IBOutlet weak var price: UILabel!
@IBOutlet weak var perSale: UILabel!

listVO.swift

var userIconImage: String?

var productImage: String?

var saleImage: String?

var userName: String?

var productName: String?

var saledPrice: String?

var price: String?

var perSale: String?

cell

cell datasource, delegate

Author:GHU,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/40970102/uicollectionview-cells-not-displaying
yy