答案 0 :(得分:2)
我一直想找几个小时的解决方案。 我展示了UIDocumentInteractionController,SFSafariViewController,UIActivityViewController,QLPreviewController。
目前,没有办法以编程方式调用Instant Markup。
唯一接近的解决方案是使用UIActivityType.markupAsPDF呈现UIActivityViewController (Documentation link)
func showMenu()
{
if let pdfUrl = Bundle.main.url(forResource: "Martin", withExtension: "pdf") {
let activityController = UIActivityViewController(activityItems: [pdfUrl], applicationActivities:nil)
ctra.excludedActivityTypes = [
UIActivityType.postToFacebook,
UIActivityType.postToTwitter,
UIActivityType.postToWeibo,
UIActivityType.message,
UIActivityType.mail,
UIActivityType.copyToPasteboard,
UIActivityType.assignToContact,
UIActivityType.saveToCameraRoll,
UIActivityType.addToReadingList,
UIActivityType.postToFlickr,
UIActivityType.postToVimeo,
UIActivityType.postToTencentWeibo,
UIActivityType.airDrop,
UIActivityType.openInIBooks,
]
// These activity types shouldn't be excluded
// UIActivityType.print,
// UIActivityType.markupAsPDF
self.present(activityController, animated: true, completion: nil)
}
}
<强> P.S。强>
如下所示,Apple使用了QLPreviewController。 我试图提供QLPreviewController,但它显示没有Instant Markup按钮。 Apple可能会在稍后向我们提供所需的API,但我对它有疑问。