Reputation: 39
I’m working on CarPlay for audio app. this is my code
if tabIndex == 0
{
let item = MPContentItem(identifier: "Tab \(tabIndex) Item")
item.title = Myarray[indexPath.row].name
item.subtitle = Myarray[indexPath.row].desc
item.artwork = MPMediaItemArtwork(image: imageLiteral(resourceName: Myarray[indexPath.row].imageURL))
item.isPlayable = true
if #available(iOS 10.0, *)
{
item.isStreamingContent = true
}
return item
}
So, the problem is this, when I load CarPlay I have 4 items with the same name/description/image. It should be 4 items with the different name, description and image. In my case all is the same. 1 item four time. The item is random. But when I click on it goes to the NowPlaying screen and it is the right item. Labels are correct and also the picture is correct. How can I fix this, please help.
Thanks
P.S. I also tested or real device
Upvotes: 1
Views: 401
Reputation: 2401
Problem: MPContentItem(identifier: "Tab (tabIndex) Item")
In your code you have set identifier as constant text that is why it's showing all items with the same name, description and image.
You have to provide unique value of identifier for each item. Then you will get the details as you want, check attached screen shot.
Upvotes: 0