小编Mei*_*ins的帖子

MPMediaItemArtwork为空,而封面在iTunes中可用

UIImage"图像"始终是空的("零"),虽然盖在苹果公司的音乐应用程序中.在iOS 7中,它运行良好,但在iOS 8中我没有封面.

我的代码有什么问题,或者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;
}
Run Code Online (Sandbox Code Playgroud)

null cover artwork mpmediaitem ios

6
推荐指数
2
解决办法
2395
查看次数

标签 统计

artwork ×1

cover ×1

ios ×1

mpmediaitem ×1

null ×1