L'immagine "UIImage
" è sempre vuota ("null") sebbene la copertina sia visualizzata nell'app musicale da Apple. in iOS 7 funziona bene, ma con iOS 8 non ottengo alcuna copertura.MPMediaItemArtwork è nullo mentre la copertina è disponibile in iTunes
Cosa c'è di sbagliato con il mio codice, o cosa è cambiato in 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;
}
sì, quando suono la stessa canzone o un album in app musicale, l'opera d'arte lì. – Meins
artwork! = Nil MA immagine == nil c'è un problema con imageWithSize:? – Meins
L'ho provato in un nuovo progetto, non funziona, qui il progetto http://www.file-upload.net/download-9572664/TestCover.zip.html – Meins