1
我有一個共享的擴展,允許用戶將圖片添加到應用程序,斯威夫特,分享推廣:NSItemProvider loadItem不工作
everytings工作得很好,但NSItemProvider .loadItem不工作
這是我在SLComposeServiceViewController代碼:
override func viewDidLoad() {
let content = extensionContext!.inputItems[0] as! NSExtensionItem
for attachment in content.attachments as! [NSItemProvider] {
let identifier = kUTTypeJPEG as String
let hasItemConforming = attachment.hasItemConformingToTypeIdentifier(identifier)
print("LOG : \(hasItemConforming)") // print True ! so item has conforming
if hasItemConforming {
attachment.loadItem(forTypeIdentifier: identifier , options: nil, completionHandler: { (coding:NSSecureCoding?, error:Error!) in
// this func not works and prints nothing
print("LOG : Loaded") // print nothing
print("LOG : error : \(error)") // print nothing
print("LOG : secureCoding : \(coding == nil)") // print nothing
})
}
}
self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
}
是否引發錯誤? – Dopapp
@Dopapp不,沒有任何反應 –
@Dopapp你是什麼意思的isActive,如果你的意思是hasItemConformingToTypeIdentifier,是的,它返回true –