我想对UITableView
从生成的 a 进行基本排序MPMediaQuery
。
我想要的只是有一个基本的歌曲列表,将歌曲分类为 A、B、C、D 等部分。应该不难,但我尝试遵循的每个教程最终都没有给我这些结果一点也不。
任何帮助都会很棒。这是我的基本代码。我意识到这甚至还没有达到我想要完成的目标,但我认为经验丰富的开发人员从这一点开始帮助我会更容易,而不是我陷入困境。
我如何生成数据:
MPMediaQuery *musicLibraryQuery = [[MPMediaQuery alloc] init];
NSArray *musicLibraryArray = [musicLibraryQuery items];
songLibrary = [NSMutableArray arrayWithArray:musicLibraryArray];
这些是我的 UITableView 方法:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [songLibrary count];
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"SongCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
MPMediaItem *song = [[songLibrary objectAtIndex:[indexPath row]] representativeItem];
cell.textLabel.text = [song valueForProperty:MPMediaItemPropertyTitle];
return cell;
}