簡體   English   中英

自定義tableview單元格說明

[英]custom tableview cell explaination

我創建了自定義 tableViewCell,我不明白為什么我需要初始化它 2 次,覆蓋 init 和 super.init,這段代碼是做什么的,請解釋一下

class tablecell: UITableViewCell {
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
    }
}

這個: super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)並不意味着你要init兩次。

super允許我們將表格視圖單元格的默認值與我們的自定義代碼一起使用。

所以super說:我將使用我自己的代碼和 defaults

更多信息: Objective-C 中的 super 到底是什么?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM