Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 自定义tableview单元格解释_Ios_Swift_Uitableview - Fatal编程技术网

Ios 自定义tableview单元格解释

Ios 自定义tableview单元格解释,ios,swift,uitableview,Ios,Swift,Uitableview,我已经创建了自定义tableViewCell,我不明白为什么我需要初始化它2次,重写init和super.init,这段代码的作用是什么,请解释一下 class tablecell: UITableViewCell { override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: .subtitle, reuseIdentifier: reuseIdenti

我已经创建了自定义tableViewCell,我不明白为什么我需要初始化它2次,重写init和super.init,这段代码的作用是什么,请解释一下

class tablecell: UITableViewCell {
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
    }
}
这:
super.init(样式:.subtitle,reuseIdentifier:reuseIdentifier)
并不意味着你要
init
两次

super
允许我们将表视图单元格的默认值与自定义代码一起使用

所以
super
说:我将使用我自己的默认代码


更多信息:

如果在init中没有执行任何操作,可以忽略该方法。从代码中可以看出,您实际上在该方法中什么都没有做。