Class 'ViewCell' has no initializers

all variables must have an initialized value in Swift except Optional.

import UIKit

 

class InterestCollectionViewCell: UICollectionViewCell {

    

    @IBOutlet weak var tuPian: UIImageView!

    

    @IBOutlet weak var wenZi: UILabel!

    

    var interet: Interest! {// 如果不确定是否有值,用?

        didSet {

            updateUI()

        }

    }

    

    fileprivate func updateUI() {

        self.tuPian?.image! = interet.featuredImage

        self.wenZi?.text! = interet.title

    }

    

    override func layoutSubviews() {

        super.layoutSubviews()

        

        self.layer.cornerRadius = 5.0

        self.clipsToBounds = true

        

    }

 

}

相关文章:

  • 2021-10-29
  • 2022-01-12
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-20
猜你喜欢
  • 2021-12-17
  • 2021-08-17
  • 2021-07-15
  • 2021-07-14
  • 2021-11-11
  • 2021-09-06
  • 2022-12-23
相关资源
相似解决方案