У меня проблемы с моим UITableVieController.Неправильно вызывать мою функцию didSelectRowAt.У меня есть несколько разделов в моем UITableView, но другой раздел моего кода с таким же точным кодом работает совершенно нормально, и я не могу понять, почему это не работает
Я уже проверил, имеет ли мое табличное представление правильноеделегат и источник данных, и это делает.
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return section == 0 ? 1 : songList.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "InfoCell", for: indexPath) as! InfoCell
cell.playlistImage.image = playlistImage
cell.name.text = selectedPlaylist
cell.nuberOfSongs.text = "Number of Songs: \(playlistCount)"
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "SongCell", for: indexPath) as! SongCell
cell.SongTitle.text = songList[indexPath.row]
cell.SongArtist.text = artistList[indexPath.row]
cell.SongImage.image = imageList[indexPath.row]
return cell
}
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section != 0 {
selectedItem = mediaList[indexPath.row]
play(selectedItem: selectedItem)
performSegue(withIdentifier: "showPlayer", sender: self)
tableView.deselectRow(at: indexPath, animated: true)
}
}
Это весь мой код для создания разделов и строк, которые идут в этих разделах.Он также содержит код для didSelectRowAt, но эта функция вообще не вызывается.