ios - Swift: Read pdf file into pdf application reader -


how can display applications can read pdf file (adobe pdf reader example) when button clicked? searched found majority use uiwebview display pdf file. how can way described?

edit: have pdf link server

try

var doccontroller:uidocumentinteractioncontroller! let pdfurl = nsurl(string: "enter_url_of_pdf")  override func viewdidload() {     super.viewdidload()     // additional setup after loading view, typically nib.     downloaddoc(pdfurl: pdfurl!) }  @ibaction func buttonaction(_ sender: anyobject) {     doccontroller.presentoptionsmenu(from: self.view.frame, in: self.view, animated: true) }  func downloaddoc(pdfurl : nsurl) {     let urltest = self.pdfurl!.absolutestring     let pdfurl = nsurl(string: urltest!)     if(pdfurl != nil){         let pdfrequest: nsurlrequest = nsurlrequest(url: pdfurl! url)          nsurlconnection.sendasynchronousrequest(pdfrequest urlrequest, queue: operationqueue.main) {(response, data, error) in             let httpresponse = response as? httpurlresponse             if(httpresponse?.statuscode == 200 && error == nil){                let documentsurl =  filemanager.default.urls(for: filemanager.searchpathdirectory.documentdirectory, in: filemanager.searchpathdomainmask.userdomainmask).first as! nsurl                 if let filename = self.pdfurl!.lastpathcomponent {                   let destinationurl = documentsurl.appendingpathcomponent(filename)                   if let data = data {                         {                             try data.write(to: destinationurl!, options: .atomic)                         } catch {                             print(error)                         }                         self.doccontroller = uidocumentinteractioncontroller(url: destinationurl!)                   }                }              }          }      }  } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -