2

mediaItemCollectionデータをに配置するのに助けが必要UITableViewです。

コード:

// Responds to the user tapping Done after choosing music.
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {    
    [self dismissModalViewControllerAnimated: YES];

    [musicPlayer stop];
    [[MPMusicPlayerController iPodMusicPlayer] stop];
    [[MPMusicPlayerController iPodMusicPlayer] setQueueWithItemCollection:mediaItemCollection];
    [[MPMusicPlayerController iPodMusicPlayer] play];
}

これmediaItemCollectionは、私が自分のに配置する必要があるものですUITableView

4

1 に答える 1

0

私はコードを見つけました:)

を宣言してその内容を設定することで、のデータを更新するときMPMediaItemCollectionにを読み取ることができます。mediaItemCollectionUITableView

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"song_cell"];

    cell = [[UITableViewCell alloc]
            initWithStyle:UITableViewCellStyleSubtitle 
            reuseIdentifier:@"song_cell"];

    MPMediaItem *anItem = [[collection items] objectAtIndex:indexPath.row];

    cell.textLabel.text = [anItem valueForProperty:MPMediaItemPropertyTitle];
    cell.detailTextLabel.text = [anItem valueForProperty:MPMediaItemPropertyArtist];

    [tableView reloadData];
}
于 2012-06-12T14:34:25.630 に答える