gpt4 book ai didi

ios - pdf 的操作扩展

转载 作者:行者123 更新时间:2023-11-29 05:15:20 25 4
gpt4 key购买 nike

我正在尝试使用扩展程序在我的应用程序中打开pdf文件,我可以使用Xcode为图像提供的默认文件来显示图像,即使我能够在未设置激活规则时显示pdf,但我们如果不指定我们在应用程序中使用的扩展程序类型,则无法发布应用程序。

尝试了很多方法都失败了我根据 stackoverflow 上的一些问题对 info.plist 做了很少的更改,但 Xcode 抛出错误,指出无法读取属性列表

<dict>
<key>NSExtensionActivationRule</key>
<string>
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf"
).@count == $extensionItem.attachments.@count
).@count == 1
</string>
</dict>

这是我的actionviewcontroller代码:

{


@IBOutlet weak var myPdfView: PDFView!

override func viewDidLoad() {
super.viewDidLoad()

// Get the item[s] we're handling from the extension context.

// For example, look for an image and place it into an image view.
// Replace this with something appropriate for the type[s] your extension supports.
for item in self.extensionContext!.inputItems as! [NSExtensionItem] {
for provider in item.attachments! {
if provider.hasItemConformingToTypeIdentifier(kUTTypePDF as String) {
// This is an image. We'll load it, then place it in our image view.
weak var weakPDFView = self.myPdfView
provider.loadItem(forTypeIdentifier: kUTTypePDF as String, options: nil, completionHandler: { (imageURL, error) in
OperationQueue.main.addOperation {
if let strongPDFView = weakPDFView {
if let imageURL = imageURL as? URL {
strongPDFView.document = PDFDocument(data: try! Data(contentsOf: imageURL))
}
}
}
})
break
}
}

}
}

@IBAction func done() {
// Return any edited content to the host app.
// This template doesn't do anything, so we just echo the passed in items.
self.extensionContext!.completeRequest(returningItems: self.extensionContext!.inputItems, completionHandler: nil)
}

}

最佳答案

Xcode is throwing error saying unable to read property list

错字。这是

</dict>

不是

<dict/>

关于ios - pdf 的操作扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59244345/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com