我有一个关于代码的顺序问题与cellForRowAt代码代码之后被称为细胞的类
执行这是我cellForRowAt功能
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! MyTableViewCell
print(1)
return cell
}
这是我的代码在我MyTableViewCell.swift
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
print(2)
}
当我运行我的代码。控制台日志打印此结果
2
1
因此,我的单元格类中的代码在cellForRowAt中的代码之前运行。
但是,我希望我的单元格类中的代码在cellForRowAt中的代码之后运行。 我想要的结果是这样的:
1
2
我怎样才能做到这样呢?
谢谢。这就是我需要的! –