我有以下代码从 MPMediaItemPropertyArtWork 获取 UIImage 以在我的视图中显示封面艺术。我从 mediaItem 获得了一个非 NULL 图稿,但是,当我尝试从图稿中提取 UIImage 时,它返回 NULL 并且我在 UIImageView 中看不到任何内容。任何帮助将不胜感激。
CGSize artworkSize = CGSizeMake(30, 30);
UIImage *artworkImage;
MPMediaItemArtwork *artwork = [song valueForProperty: MPMediaItemPropertyArtwork];
if (artwork) {
NSLog(@"artwork available");
artworkImage = [artwork imageWithSize:artworkSize];
} else {
NSLog(@"artwork not available");
artworkImage = [UIImage imageNamed:@"EmptyAlbum.png"];
}
NSLog(@"artworkImage = %@", artworkImage);
coverArtView.image = artworkImage;