1

Ich möchte mehrere Videos in einer Sammlungsansicht anzeigen. Ich habe diesen Code:Video in der Sammlungsansichtszelle anzeigen

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

} 

Aber der Code ist sehr langsam und das Scrollen ist nicht glatt. Kannst du mir helfen?

Antwort

Verwandte Themen