作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将 Fusuma 用于我的图像和视频库。我对滚动画廊 View (FSAlbumView.swift) 有疑问。当我滚动时,它会交换视频缩略图,或者代替视频缩略图出现图像缩略图,图像缩略图没有任何问题,问题仅在于视频缩略图。
这是我的代码。
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("FSAlbumViewCell", forIndexPath: indexPath) as! FSAlbumViewCell
let currentTag = cell.tag + 1
cell.tag = currentTag
let asset = self.images[indexPath.item] as! PHAsset
if(asset.mediaType == .Image){
self.imageManager?.requestImageForAsset(asset,
targetSize: cellSize,
contentMode: .AspectFill,
options: nil) {
result, info in
if cell.tag == currentTag {
cell.image = result
}
}
}else if(asset.mediaType == .Video){
self.imageManager?.requestAVAssetForVideo(asset, options: nil, resultHandler: {(asset: AVAsset?, audioMix: AVAudioMix?, info: [NSObject : AnyObject]?) in
//dispatch_async(dispatch_get_main_queue(), {
let asset = asset as? AVURLAsset
if asset?.URL.absoluteString != nil{
self.videoURLArray.append([indexPath.row:(asset?.URL.absoluteString)!])
}
if cell.tag == currentTag {
cell.video = asset?.URL
// self.videoURLArray[indexPath.row] = (asset?.URL.absoluteString)!
print(asset?.URL)
}
//..var data = NSData(contentsOfURL: asset!.URL)
//})
})
}
return cell
}
最佳答案
我们也遇到了同样的问题。我们所做的是在下面给出。不知道这样对不对。
评论下面的语句。
let currentTag = cell.tag + 1
cell.tag = currentTag
添加用以下代码片段替换 if-else block
self.imageManager?.requestImageForAsset(asset, targetSize: cellSize, contentMode: .AspectFill, options: nil){
result, info in
if(asset.mediaType == .Video){
self.imageManager?.requestAVAssetForVideo(asset, options: nil, resultHandler: {(asset: AVAsset?, audioMix: AVAudioMix?, info: [NSObject : AnyObject]?) in
let asset = asset as? AVURLAsset
if asset?.URL.absoluteString != nil{
self.videoURLArray.append([indexPath.row:(asset?.URL.absoluteString)!])
}
})
}
cell.image = result
}
关于swift - Fusuma Album View video 拇指交换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40301792/
我正在使用Fusuma对于图像视频应用程序。我需要相机胶卷的所有资源(图像和视频)。这里 PHAsset 用于选择 Assets 。这里仅显示图库图像。但我想显示库部分中的所有图像和视频。任何人都可以
我将 Fusuma 用于我的图像和视频库。我对滚动画廊 View (FSAlbumView.swift) 有疑问。当我滚动时,它会交换视频缩略图,或者代替视频缩略图出现图像缩略图,图像缩略图没有任何问
我在我的项目中使用 Fusuma pod,但在最新的 iOS 13 中,存在一个与从图库中选择的图像相关的错误。 确切地说,如果选择的图像来自图库(在带有 ios 13 的 iPhone 设备上,而不
我正在使用 github 上的 Fusuma 项目。如果我从带有 Fusuma 的库中选择照片并将其上传到我的服务器,一切都可以。但如果我用 Fusuma 相机拍照,它会旋转 90 度。我尝试在 ph
我是一名优秀的程序员,十分优秀!