首页 > 编程语言 > 详细

swift两种获取相册资源PHAsset的路径的方法(绝对路径)

时间:2018-07-25 14:13:44      阅读:1062      评论:0      收藏:0      [点我收藏+]

方法中使用到的phasset就是我们取到的PHAsset对象

方法一:

 1 let options = PHVideoRequestOptions()
 2 
 3 options.version = PHVideoRequestOptionsVersion.current
 4 
 5 options.deliveryMode = PHVideoRequestOptionsDeliveryMode.automatic
 6 
 7 let manager =PHImageManager.default()
 8 
 9 manager.requestAVAsset(forVideo: phasset, options: options, resultHandler: { (asset, audioMix, info) in
10 
11        let strArr =     ((info!asNSDictionary).object(forKey:"PHImageFileSandboxExtensionTokenKey")as!NSString).components(separatedBy:";")
12 
13        let url = strArr.last!
14 
15        print(url)
16 
17 })

 

方法二(比较简洁):

1 PHCachingImageManager().requestAVAsset(forVideo: phasset as PHAsset, options:nil, resultHandler: { (asset, audioMix, info) in
2 
3          let strArr =     ((info!asNSDictionary).object(forKey:"PHImageFileSandboxExtensionTokenKey")as!NSString).components(separatedBy:";")
4 
5         let url = strArr.last!
6 
7         print(url)
8 
9 })

 

 

swift两种获取相册资源PHAsset的路径的方法(绝对路径)

原文:https://www.cnblogs.com/-yun/p/9365546.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!