Fusuma相册查看视频拇指交换
Posted
技术标签:
【中文标题】Fusuma相册查看视频拇指交换【英文标题】:Fusuma Album View video thumbs swaping 【发布时间】:2016-10-28 09:12:15 【问题描述】:我将 Fusuma 用于我的图片和视频库。 我对滚动画廊视图 (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
【问题讨论】:
【参考方案1】:我们也遇到了同样的问题。我们所做的是在下面给出。不知道对不对。
评论以下陈述。
let currentTag = cell.tag + 1
cell.tag = currentTag
添加用以下代码sn-p替换if-else块
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
【讨论】:
以上是关于Fusuma相册查看视频拇指交换的主要内容,如果未能解决你的问题,请参考以下文章