【发布时间】:2020-07-06 01:26:00
【问题描述】:
我正在尝试用歌曲、艺术家和专辑填充表格视图。这在我的 sql 数据库中的同一个表中,但在不同的列中。到目前为止,我只有歌曲,但没有艺术家和专辑。
var searchActive: Bool = false
var search = [Search]()
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
if (searchActive) {
cell.textLabel?.text = search[indexPath.row].cleanSong
cell.textLabel?.text = search[indexPath.row].artists
cell.textLabel?.text = search[indexPath.row].albums
} else {
searchActive = true
}
return cell;
}
【问题讨论】:
-
你需要不同的部分来解决这个特定的问题
-
您必须以可以在不同部分显示的方式创建数据。您在 cell for row 方法中的现有实现将覆盖相册中的数据。