尝试为cloudkit共享创建缩略图,但是

时间:2018-10-10 09:10:13

标签: ios swift image thumbnails cloudkit

iOS 11.x Swift 4.2

创建cloudKit共享并为其设置权限。一切看起来都不错,并且可以正常工作,但是对于缩略图,我得到了以下错误消息,这是我无法接受的。在说什么?

  

2018-10-10 11:04:14.422093 + 0200 n2k备注[12256:5302161]   [DocumentManager]无法关联所选URL的缩略图   文件:///private/var/mobile/Library/Mobile%20Documents/com~apple~CloudDocs/Desktop/August2018/App/Icons/noun_Puzzle_787736.png   与收件箱副本   文件:///private/var/mobile/Containers/Data/Application/D13D04E1-8700-4B3E-AD0B-710D037B5253/tmp/ch.cqd.blah-Inbox/noun_Puzzle_787736.png:   错误域= QLT缩略图代码= 2“(null)”   UserInfo = {NSUnderlyingError = 0x1c444b070 {Error   域= GSLibraryErrorDomain代码= 3“找不到生成”   UserInfo = {NSDescription =找不到生成}}}

我的代码看起来像这样...

let share = CKShare(rootRecord: customRecord)
share[CKShare.SystemFieldKey.title] = "Marley" as CKRecordValue
share[CKShare.SystemFieldKey.shareType] = "ch.cqd.blah" as CKRecordValue

let imageData = image2Save.pngData()!
let options = [
        kCGImageSourceCreateThumbnailWithTransform: true,
        kCGImageSourceCreateThumbnailFromImageAlways: true,
        kCGImageSourceThumbnailMaxPixelSize: 300] as CFDictionary
let source = CGImageSourceCreateWithData(imageData as CFData, nil)!
let imageReference = CGImageSourceCreateThumbnailAtIndex(source, 0, options)!
let thumbnail = UIImage(cgImage: imageReference).pngData()
share[CKShare.SystemFieldKey.thumbnailImageData] = thumbnail! as CKRecordValue

image2Save是我随后显示的有效UIImage。添加了代码以在屏幕上显示缩略图。缩略图看起来不错。

0 个答案:

没有答案