我已经尝试了几个小时寻找解决方案。
我使用了UIDocumentInteractionController、SFSafariViewController、UIActivityViewController和QLPreviewController等工具。
目前,没有办法通过编程方式调用即时标记(Instant Markup)。
唯一接近的解决方案是使用UIActivityType.markupAsPDF来呈现UIActivityViewController,详情请参见文档链接。
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)
}
}