雖然封面是在蘋果音樂應用程序中顯示的,但「圖片」始終爲空(「null」)。 在iOS 7中可以正常工作,但是在iOS 8中我沒有任何掩護。MPMediaItemArtwork爲空,但封面在iTunes中可用
我的代碼有什麼問題,或者iOS 8中發生了什麼變化?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
AlbumCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AlbumCell"];
MPMediaItemCollection *song = self.songsList[indexPath.row];
cell.albumName.text = [[song representativeItem] valueForProperty: MPMediaItemPropertyAlbumTitle];
cell.albumArtist.text = [[song representativeItem] valueForProperty:MPMediaItemPropertyAlbumArtist];
CGSize artworkImageViewSize = CGSizeMake(100, 100);
MPMediaItemArtwork *artwork = [song valueForProperty:MPMediaItemPropertyArtwork];
UIImage *image = [artwork imageWithSize:artworkImageViewSize];
NSLog(@"-------------------");
NSLog(@"%@",[[song representativeItem] valueForProperty: MPMediaItemPropertyAlbumTitle]);
NSLog(@"%@",image);
if (artwork) {
cell.cover.image = image;
}
else
{
cell.cover.image = [UIImage imageNamed:@"nocover.png"];
}
return cell;
}
是的,當我玩的音樂應用程序相同的歌曲或專輯,作品在那裏。 – Meins 2014-09-24 07:37:35
作品!=無但是圖像==無 imageWithSize有問題嗎? – Meins 2014-09-24 07:51:11
我試過它在一個新的項目,它不工作,這裏的項目 http://www.file-upload.net/download-9572664/TestCover.zip.html – Meins 2014-09-24 08:18:33