MPMediaItemCollection 删除选定的队列/集合?
我目前正在查看 Apple 的 AddMusic 示例 并播放在我开始将其重写到我的应用程序中之前,先对其进行处理。
我注意到它制作了自己的小歌曲播放列表。我想使用表格视图上的滑动操作来删除用户错误单击的歌曲。
我已经实现了滑动操作,但无法找出删除该特定行的方法?
任何想法都很棒,下面是添加它的代码。我尝试做相反的事情但没有运气。如果不可能的话我该怎么办?
干杯
MainViewController *mainViewController = (MainViewController *) self.delegate;
MPMediaItemCollection *currentQueue = mainViewController.userMediaItemCollection;
MPMediaItem *anItem = (MPMediaItem *)[currentQueue.items objectAtIndex: row];
I am currently looking at Apple's AddMusic example and playing around with it before I start rewriting it into my application.
I noticed that it makes its own little playlist of the songs qued. I want to use the swipe action on the table view to remove songs that a use clicked by mistake.
I have implemented the swipe action but can't work out a way to delete that specific row?
Any idea would be great, below is the code to add it. I tried doing the reverse with no luck. If it's not possible how should I go about it?
Cheers
MainViewController *mainViewController = (MainViewController *) self.delegate;
MPMediaItemCollection *currentQueue = mainViewController.userMediaItemCollection;
MPMediaItem *anItem = (MPMediaItem *)[currentQueue.items objectAtIndex: row];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MPMediaItemCollection 是不可变的,即。您无法更改这些项目。您需要创建一个新项目,其中包含除要删除的项目之外的所有项目。请参阅下文:
小心不要创建空集合。这是不允许的,MPMediaItemCollection 将引发异常。
An MPMediaItemCollection is immutable, ie. you can't change the items. You need to create a new one with all items less the one you want to remove. See below:
Be careful to not create an empty collection. It's not allowed and the MPMediaItemCollection will raise an exception.