我们如何通过Swift 5

问题描述

我正在使用以下代码从iPhone的相册中获取视频的URL。 然后我可以在应用程序中打开任何我想要的 我找不到用于图像的类似方法。 :(

var videoList: [String] = []
var videoListURL: [NSURL] = []

// Gets all the video file list from phone library
func fetchAllVideos() {
    videoListURL.removeAll()
    videoList.removeAll()
    let fetchOptions = PHFetchOptions()
    
    fetchOptions.predicate = NSPredicate(format: "mediaType = %d ",PHAssetMediaType.video.rawValue )
    
    let allVideo = PHAsset.fetchAssets(with: .video,options: fetchOptions)
    
    allVideo.enumerateObjects { (asset,index,bool) in
        
        let imageManager = PHCachingImageManager()
        let options = PHVideoRequestOptions()
        options.isNetworkAccessAllowed = false
        imageManager.requestAVAsset(forVideo: asset,options: options,resultHandler: { [self]  (video,audioMix,info) in
                                      
                                        guard  let video2 = video as? AVURLAsset
                                        else {return}
                                        
                                        
                                        let urlVideo = video2.url
                                        
                                        videoListURL.append(urlVideo as NSURL)
                                        var names = urlVideo.lastPathComponent
                                        if names.contains("MOV") {
                                            names.removeLast(4)
                                            self.videoList.append(names)
                                        }
                                        
                                       
                                    })
      
        
    }
} 

解决方法

您应该使用函数$ git merge left Merge made by the 'recursive' strategy. dir_1/file_left.txt | 1 + 1 file changed,1 insertion(+) create mode 100644 dir1/file_left.txt # in git's storage : there are two distinct directories dir_1 and Dir_1 $ git ls-tree HEAD 040000 tree d6317389dbdebb9fcec7a5f60ba49666bb55cdfb Dir_1 100644 blob 72943a16fb2c8f38f9dde202b7a70ccc19c52f34 README.txt 040000 tree 9cd36c945344bf39eb3b3fcb642f791f80847dbf dir_1 $ git ls-tree HEAD:Dir_1 100644 blob 5716ca5987cbf97d6bb54920bea6adde242d87e6 file_right.txt $ git ls-tree HEAD:dir_1 100644 blob 257cc5642cb1a054f08cc83f2d943e56fd3ebe99 file_left.txt # when checked out on disk,both directories get "merged" # (which name wins depends on the order in which the directories were created on disk) $ ls README.txt Dir_1/ $ ls Dir_1/ file_left.txt file_right.txt 间接捕获URL
您的功能或多或少会在下面,但我认为它将对您有用

requestContentEditingInput

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...