首页 > 代码库 > Class 'ViewCell' has no initializers

Class 'ViewCell' has no initializers

Class ‘ViewCell‘ has no initializers

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

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; min-height: 16.0px } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #ba2da2 } p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #4f8187 } p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #3e1e81 } p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #703daa } span.s1 { color: #ba2da2 } span.s2 { } span.s3 { color: #703daa } span.s4 { color: #000000 } span.s5 { color: #4f8187 } span.s6 { color: #31595d } span.s7 { color: #272ad8 }</style>

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

        

    }

 

}

Class 'ViewCell' has no initializers