我想显示一个UITableView,只显示设备上当前的歌曲.
如果我查询所有项目我(显然)获得所有项目,包括我购买但未下载的项目.
这是代码的(部分)
@property (strong,nonatomic) NSMutableArray *songsList; - (void)viewDidLoad { [super viewDidLoad]; self.tableView.delegate = self; self.tableView.dataSource = self; MPMediaQuery *everything = [[MPMediaQuery alloc] init]; NSArray *itemsFromGenericQuery = [everything items]; self.songsList = [NSMutableArray arrayWithArray:itemsFromGenericQuery]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.songsList.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static Nsstring *cellIdentifier = @"TableCellID"; TableCellTitle *tablecell = (TableCellTitle *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; MPMediaItem *song = [self.songsList objectAtIndex:indexPath.row]; Nsstring *songTitle = [song valueForProperty: MPMediaItemPropertyTitle]; tablecell.cellSongname.text = songTitle; return tablecell; }
我已经阅读了一些关于涉及的事情
[song valueForProperty:MPMediaItemPropertyIsCloudItem]
但是不能像我上面解释的那样让它工作.
有什么建议?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。