【发布时间】:2015-03-21 20:01:47
【问题描述】:
我正在尝试使用MPMediaQuery 访问用户的本地音乐库,以按以下方式对结果进行排序:
Artist A (sorted alphabetically) > All of Artist A's albums, sorted alphabetically
Artist B (sorted alphabetically) > All of Artist B's albums, sorted alphabetically
Artist C (sorted alphabetically) > All of Artist C's albums, sorted alphabetically
...
我的查询结构如下:
MPMediaQuery *albumsQuery = [MPMediaQuery albumsQuery];
albumsQuery.groupingType = MPMediaGroupingAlbumArtist;
但问题是,虽然上述大部分都有效,但只返回每个给定艺术家的第一张专辑。也就是说,只返回 Alt-J 的一张专辑,而不是库中存在的两张专辑。
这是为什么呢?以及如何构造我的查询以返回所需的结果?
编辑:这是我访问相册查询的方式:
AlbumCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellID forIndexPath:indexPath];
MPMediaItemCollection *collection = [_items objectAtIndex:indexPath.row];
MPMediaItem *cellItem = [collection representativeItem];
其中_items 是一个包含MPMediaQuery 的结果的NSArray。
【问题讨论】:
标签: ios iphone mpmediaquery mpmedialibrary