I've been trying to find out a solution for several hours. I presented UIDocumentInteractionController, SFSafariViewController, UIActivityViewController, QLPreviewController.
And for now, there is NO WAY to call Instant Markup programmatically.
The only near solution is to present UIActivityViewController with UIActivityType.markupAsPDF ( 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)
}
}
In the bottom line of extension apps, you will see "Create PDF".
PS
As you can see following screenshots, Apple uses QLPreviewController. I've tried to present QLPreviewController, but it shows without Instant Markup button. It could be that Apple will provide us the required API later, but I have doubts about it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.