IOS Swift assetForURL错误

IOS Swift assetForURL错误,第1张

概述我只是想从使用 Swift的ios 8中的ALAsset获取图像资源. 我使用SNImagePicker进行多个图像拾取. 使用objective-c我使用: for (int i = 0; i < info.count; i++) { ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init]; [assetLibra 我只是想从使用 Swift的ios 8中的ALAsset获取图像资源.

我使用SNImagePicker进行多个图像拾取.

使用objective-c我使用:

for (int i = 0; i < info.count; i++) {    ALAssetsLibrary *assetlibrary=[[ALAssetsLibrary alloc] init];    [assetlibrary assetForURL:info[i] resultBlock:^(ALAsset *asset) {        UIImage *image = [UIImage imageWithCGImage:[asset aspectRatiothumbnail]];    } failureBlock:^(NSError *error) {     }];

有了swift,我试着这样做:

func imagePicker(imagePicker: SNImagePickerNC!,dIDFinishPickingWithMediaInfo info: NSMutableArray!){    var i: Int = Int(0);    for (i; i < info.count as Int; i++){        var url: NSURL = info[i] as NSURL        var assetlibrary: ALAssetsLibrary = ALAssetsLibrary()        //        //assetlibrary.assetForURL(NSURL?(),resultBlock: ALAssetsLibraryAssetForURLResultBlock?(),failureBlock: ALAssetsLibraryAccessFailureBlock?())                    //        assetlibrary.assetForURL(url,resultBlock: {            (asset: ALAsset!) in            if asset != nil {                var assetRep: ALAssetRepresentation = asset.defaultRepresentation()                var iref = assetRep.fullResolutionImage().takeUnretainedValue()                var image =  UIImage(CGImage: iref)                self.imageVIEwPrevIEw.contentMode = UIVIEwContentMode.ScaleAspectFill                self.imageVIEwPrevIEw.image = image            }            },failureBlock: {                (error: NSError!) in                NSLog("Error!",nil)            }        )    }}

使用此代码段,我收到错误

Type ‘CVararg’ does not conform to protocol ‘NilliteralConvertible’

解决方法 尝试用NSLog替换NSLog(“Error!”,nil)(“Error!”).此语句导致Swift抛出意外的错误消息. 总结

以上是内存溢出为你收集整理的IOS Swift assetForURL错误全部内容,希望文章能够帮你解决IOS Swift assetForURL错误所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1114128.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存