【问题标题】:Place mediaItemCollection data in UITableView在 UITableView 中放置 mediaItemCollection 数据
【发布时间】:2011-10-30 23:29:31
【问题描述】:

我需要一些帮助,将 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 的内容。

【问题讨论】:

    标签: uitableview xcode4 mpmediaitemcollection


    【解决方案1】:

    I found the code :)

    通过声明MPMediaItemCollection 并设置其内容,我可以在更新UITableView 的数据时读取mediaItemCollection

    - (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];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-22
      相关资源
      最近更新 更多