1

컬렉션보기에서 여러 개의 비디오를 표시하려고합니다. 이 코드를 가지고 :컬렉션보기 셀에 비디오 표시

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 
    return array.count; 
} 


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; 

    NSURL *videoURL = [NSURL fileURLWithPath:@"Path"]; 
    AVPlayer *player = [AVPlayer playerWithURL:videoURL]; 
    AVPlayerViewController *playerViewController = [AVPlayerViewController new]; 
    playerViewController.player = player; 
    playerViewController.showsPlaybackControls = NO; 
    playerViewController.videoGravity = AVLayerVideoGravityResizeAspectFill; 

    playerViewController.view.frame = CGRectMake(0, 0, 200, 200); 
    [cell insertSubview:playerViewController.view atIndex:0]; 

    [player play]; 

    return cell; 

} 

그러나 코드가 매우 느리고 스크롤이 원활하지 않습니다. 너 나 좀 도와 줄 수있어?

답변

관련 문제