I get a PDF in Json, retrieve it and have it displayed in a webview, but I also need it to be shared with the UIActivityViewController, but when I pass the webview it does not show options available for sharing
I am doing the following:
//I get the json
if let url = URL(string: "http://10.1.80.106:9000/api/recibo/imprimir?vigencia=2015-06-30") {
var urlRequest = URLRequest(url: url)
urlRequest.setValue("application/pdf", forHTTPHeaderField: "Content-Type")
urlRequest.setValue("aaaabbbccc", forHTTPHeaderField: "Authorization")
//i create the webview
let webView = UIWebView(frame: self.view.frame)
webView.loadRequest(urlRequest as URLRequest)
webView.scalesPageToFit = true
let pdfVC = UIViewController()
pdfVC.view.addSubview(webView)
pdfVC.title = "Recibo de Pagamento"
self.navigationController?.pushViewController(pdfVC, animated: true)
//instantiate the UIActivityViewController for the share, and step the WebView as parameter
let vc = UIActivityViewController(activityItems: [(webView.request?.url?.absoluteString) as Any], applicationActivities: [])
if let popoverController = vc.popoverPresentationController {
popoverController.sourceView = self.view
popoverController.sourceRect = self.view.bounds
}
self.present(vc, animated: true, completion: nil)
}