gpt4 book ai didi

iphone - 无法从 MPMediaItemPropertyArtWork 获取 UIImage

转载 作者:行者123 更新时间:2023-12-03 19:12:01 29 4
gpt4 key购买 nike

我有以下代码从 MPMediaItemPropertyArtWork 获取 UIImage 以在我的 View 中显示 coverArt。我从 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;

最佳答案

尝试一下 - 使用 UItableview 来显示专辑详细信息。

声明 MPMediaItemCollection *userMediaCollection;

 -(void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {

[self setUserMediaCollection:mediaItemCollection];

[self dismissModalViewControllerAnimated:YES];

}


MPMediaItem *mItem = (MPMediaItem *)[userMediaCollection.items objectAtIndex:indexPath.row];

MPMediaItemArtwork *artWork = [mItem valueForProperty:MPMediaItemPropertyArtwork];

cell.imageView.image = [artWork imageWithSize:CGSizeMake(30, 30)];

其中 userMediaCollection 是您的 MPMediaItemCollection

关于iphone - 无法从 MPMediaItemPropertyArtWork 获取 UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6604829/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com