0
所以,我有收集視圖,並可以從那裏下載PDF文件,我得到這樣的路徑file:///Users/community/Library/Developer/CoreSimulator/Devices/F9AB746D-20C3-4333-AE70-2840538F4AED/data/Containers/Data/Application/977E843C-15D6-4169-9980-1EBD5CBE3660/Library/Caches/81791.pdf
它可以查看文件,但是當我使用路徑這得到相同的路徑下載,文件但無法打開文件
Optional(file:///Users/crocodic/Library/Developer/CoreSimulator/Devices/F9AB746D-20C3-4333-AE70-2840538F4AED/data/Contai ... 358.pdf) it can't view the file.
我該怎麼辦?在迅速
這裏是我的代碼
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let mainStoryBoard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc:RedirectMagazineViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("NEXT") as! RedirectMagazineViewController
if (self.localPathArray.count > indexPath.row) {
vc.receiveData = NSURL(string: databaseResult[0].pathDatabase)! // here i pass the path downloaded file to next view controller
}
vc.receiveTitle = titleMagazine[indexPath.item]
self.navigationController?.pushViewController(vc, animated: true)
}
和我的第二個視圖控制器上查看PDF文件
var path = ""
var receiveData: NSURL!
var receiveTitle: String = ""
override func viewDidLoad() {
self.navigationController?.navigationBarHidden = false
self.title = receiveTitle
activityIndicator.startAnimating()
self.webView.loadRequest(NSURLRequest(URL: receiveData))
}
請顯示您嘗試的代碼,它看起來像您正在使用您的路徑var可選包裝。 –
我編輯問題 –