私のアプリでは、Artistをロードし、に入力しarrayOfArtistsて表示しUITableViewます。
だから私は自分UITableViewのインデックスを作成する必要があります。そのため、iOSの組み込みの音楽アプリのようにアーティストの配列をアルファベット順に並べ替える必要があります。

上の写真のように、でインデックスを付けることができUITableViewますTitle。
そのため、ArtistArrayをアルファベット順に並べ替える必要があります。
どうやってやるの?
これが私がiPodLibraryからArtistをロードするいくつかのコードです。
のViewDidLoad
MPMediaQuery *query = [MPMediaQuery artistsQuery];
query.groupingType = MPMediaGroupingAlbumArtist;
self.arrayOfArtist = [query collections];
のCellForRowAtIndexPath
cell.textLabel.text = [NSString stringWithFormat:@"%@",[[[self.arrayOfArtist objectAtIndex:indexPath.row] representativeItem] valueForProperty:MPMediaItemPropertyArtist]];
のsectionForSectionIndexTitle
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
return 1;
}
と
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.arrayOfArtist count];
}
そして、私は私のインデックスを作成するためTitleHeaderにアルファベット順で表示したいと思います。どうやってやるの?みんなありがとう。UITableViewUITableView
