私はUIDocumentInteractionController.Butを使ってpdfを表示するためにこのコードを書いていますが、ローカルディレクトリでpdfを検索し、iOS 8以降で開く方法はわかりません。iOS 8でPDFのURLを開きますか?
let filename = history.invoiceLongDate // 01223642
if !filename.isEmpty{
let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let docs = paths[0]
let pathURL = NSURL(fileURLWithPath: docs, isDirectory: true)
if #available(iOS 9.0, *) {
let fileURL = NSURL(fileURLWithPath: "\(filename)_my_invoice.pdf", isDirectory: false, relativeToURL: pathURL)
self.docController = UIDocumentInteractionController(URL: fileURL)
self.docController?.delegate = self
self.docController?.presentOptionsMenuFromRect(sender.frame, inView: self.view, animated: true)
} else {
// Fallback on earlier versions
// Any Help with that?
}
}
私はwebview.IがUIDocumentInteraction.Anyヘルプを使用する場合に使用したくありませんか? –
さて、この 'presentOpenInMenuFromRect'を使って試してみましたか?このリンクを参照してください:http://stackoverflow.com/questions/25430069/uidocumentinteractioncontroller-displaying-blank-pdf –
問題は、 "let fileURL = NSURL(fileURLWithPath:" \(filename)_my_invoice.pdf "、isDirectory:false 、relativeToURL:pathURL) "NSURLを意味し、fileURLWithPathはios 9ではなくios 9でのみ利用可能です。 –