【发布时间】:2019-06-27 17:52:21
【问题描述】:
我一直在慢慢构建一个音乐播放器。我查询专辑数据以填充表格。如果用户选择一张专辑,我们会转到一个新屏幕来选择要播放的歌曲。我想制作专辑表的第一行(在专辑视图控制器中),成为名为“所有歌曲”的行,但我无法弄清楚如何做到这一点。
我曾尝试使用:insertRowsAtIndexPaths。但是没有成功。
@IBOutlet var albumsTableView: UITableView!
let qryAlbums = MPMediaQuery.albums() // Query the albums
// Set the cell in the table
func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell {
// I am using the custom class that I created called: myCustomAlbumTableViewCell
let cell = tableView.dequeueReusableCell(withIdentifier: "albumIdCell", for: indexPath) as! myCustomAlbumTableViewCell
let rowItem = qryAlbums.collections![indexPath.row]
cell.albumTitle.text = rowItem.items[0].albumTitle
return cell
}
【问题讨论】:
标签: swift collections tableview xcode9 mpmediaquery