小编Jam*_*s64的帖子

如果选中编译,iOS MPMediaQuery.artistsQuery() 不会返回每个艺术家

我一直在使用 Swift 2.3 编写音乐应用程序。我发现的问题是我的 MPMediaQuery.artistsQuery() 没有提供所有的艺术家。使用 iTunes,我已经追踪到如果“专辑是不同艺术家的歌曲汇编”被选中,那么该艺术家将不会出现在我的 tableView 中。例如,我使用 iTunes 导入的其中一张 CD(没有出现在我的 tableView 中)是:Little River Band,Greatest Hits。iTunes 似乎认为它是各种艺术家的合集,虽然我不同意,但我仍然需要处理这个场景。

var qryArtists = MPMediaQuery.artistsQuery()
qryArtists.groupingType = MPMediaGrouping.Artist

// Set the cell in the table
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    // I am using the custom class that I created called: myCustomArtistTableViewCell
    let cell = tableView.dequeueReusableCellWithIdentifier("artistIdCell", forIndexPath: indexPath) as! myCustomArtistTableViewCell

    let currLoc = qryArtists.collectionSections![indexPath.section].range.location
    let rowItem = qryArtists.collections![indexPath.row + currLoc]

    cell.artistTitle.text = rowItem.items[0].artist

    return cell
}
Run Code Online (Sandbox Code Playgroud)

表中的所有部分都很好。我只是想念一些艺术家,包括:小河乐队。

此外,我的示例专辑中每首歌曲的艺术家标签都包含字符串:Little River …

mpmediaquery ios swift2

2
推荐指数
1
解决办法
512
查看次数

标签 统计

ios ×1

mpmediaquery ×1

swift2 ×1