在我的 UICollectionView 我有一个单元格。这是我的cellForItemAtIndexPath
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
{
var videoCell = collectionView.dequeueReusableCellWithReuseIdentifier("cellVideo", forIndexPath: indexPath) as? CollectionViewCell
let post = self.arrayOfDetails[indexPath.row]
var myUrl = post.image // post.image is image url
let fileUrl = NSURL(string: post.image)
aPlayer = AVPlayer(URL: fileUrl)
moviePlayerController.player = aPlayer
moviePlayerController.view.frame = CGRectMake(8, 8, videoCell!.frame.size.width-16, 310)
moviePlayerController.videoGravity = AVLayerVideoGravityResizeAspectFill
moviePlayerController.view.sizeToFit()
moviePlayerController.showsPlaybackControls = true
videoCell!.addSubview(moviePlayerController.view)
return videoCell!
}
问题是 AVPlayerViewController 没有出现在每个单元格上。但仅在我正在查看的单元格下方的单元格上,因此如果我在 UICollectionView 中向下滚动并且一旦屏幕上出现一个新单元格,则 AVPlayerViewController 位于该单元格上,而不是屏幕中间的单元格。有什么建议我可能在这里错了吗?
视频在这里:https ://vid.me/e/fU5X