【发布时间】:2020-12-23 19:40:49
【问题描述】:
我创建了一个包含两个部分的 UITableView。现在我正在尝试填充一个部分。当我执行操作时,我的程序会同时使用相同的文本填充两个部分。我要做的是填充第一部分,然后最终将其中一个单元格从第 1 部分移动到第 2 部分。到目前为止,我到了这里:
extension ListVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
randomCount = notes.count
return notes.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: CustomNoteCell.reuseId) as! CustomNoteCell
cell.set(with: notes[indexPath.row])
return cell
}
func numberOfSections(in tableView: UITableView) -> Int {
sections.count
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if section < sections.count {
return sections[section]
}
return nil
}
}
我相信它需要在 cellForRowAt 中发生,但我不知道如何指定部分。任何帮助和线索表示赞赏。非常感谢;)
【问题讨论】: