Pergunta

I am trying to add Genre Artwork into my UITableViewCell in iOS like following pic.

enter image description here

I think there is no built-in artwork for Genre. I am using MediaPlayer Framework and i can add MPMediaItemPropertyArtwork. But i have no idea how to add Genre artwork.

How can i do it? Any Ideas are also welcome.

Foi útil?

Solução

You could search through all available songs, pull out the MPMediaItemPropertyGenre string.

From there you could get the list of available genres and then you could either have your own custom artwork for the genre or you could get a random album artwork from a song in that genre using MPMediaItemPropertyArtwork.

Note this is untested code. In your cellForRowAtIndexPath do something like this.

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

MPMediaItemArtwork *artWork = [mItem valueForProperty:MPMediaItemPropertyArtwork];

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

If you want to add your own custom artwork you could just set the cell image.

cell.imageView.image = [UIImage imageNamed:@"Rock"];

Outras dicas

I give you to basic ideas for how to add this types of Art as you need.

It is custom UITableViewCell, it is consist of 3 controllers

1) UIImageView (main Image)
2) UILabel 
3) UIImageView (for put cell BackGround Image)

All The Controllers add in cell.contentView With Setting a UITableViewCell accessory type on some cell UITableViewCellAccessoryDisclosureIndicator.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top