2014-02-23 103 views

回答

0

使用UICollectionView

1)低效的方式:如果你想同時播放所有媒體。 媒體播放器的網格視圖。

 

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView  cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CollectionCell forIndexPath:indexPath]; 

    // get URL 
    Player *mediaPlayer = [[self playerArray]objectAtIndex:indexPath.row]; 

    NSURL* videoURL = [NSURL URLWithString:mediaPlayer.url]; 
    MPMoviePlayerController* mPlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL]; 
    [mPlayer prepareToPlay]; 
    [mPlayer play]; 

    //For viewing partially..... 
    [mPlayer.view setFrame:CGRectMake(/*Your frame*/)]; 
    [mPlayer.view.backgroundColor = [UIColor grayColor]; 
    [cell addSubview:mPlayer.view]; 

    return cell; 

} 

2)高效的方式:將用縮略圖的網格,當用戶點擊一個單元格(在這種情況下,發生在didSelectRow上面的代碼)

相關問題