当我使用MediaPicker时,我想要带有歌曲的图像。
代码:
NSMutableArray *arr = [NSMutableArray arrayWithArray:mediaItemCollection.items];
for (int i =0; i<=[arr count]-1; i++) {
MPMediaItem *selectedSong = [[mediaItemCollection items] objectAtIndex:i];
titleString = [selectedSong valueForProperty:MPMediaItemPropertyTitle];
}
titleString
是我的阵列。
答案 0 :(得分:0)
试试这个:
NSMutableArray *arr = [NSMutableArray arrayWithArray:mediaItemCollection.items];
for (int i =0; i<=[arr count]-1; i++) {
MPMediaItem *selectedSong = [[mediaItemCollection items] objectAtIndex:i];
titleString = [selectedSong valueForProperty:MPMediaItemPropertyTitle];
MPMediaItemArtwork *artWorkItem = [selectedSong valueForProperty:MPMediaItemPropertyArtwork];
UIImage *coverImage = NULL;
if(artWorkItem)
coverImage = [artWorkItem imageWithSize:CGSizeMake(100, 100)];
if(coverImage)
myImageView.image = coverImage;
else
{
NSLog(@"No album Artwork!!!");
myImageView.image = [UIImage imageNamed:@"default"];
}
}