1
我想在Web視圖中顯示PDF文件。對於我寫的代碼,如:Webview未從文檔目錄加載PDF文件
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"201507234Surat_GDCR.pdf"];
self.pdfWeb.hidden=FALSE;
self.JantriImage.hidden=TRUE;
self.pdfWeb.delegate=self;
self.pdfWeb = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,ScreenWidth,ScreenHeight-64)];
self.pdfWeb.scalesPageToFit = YES;
NSURL *url = [NSURL fileURLWithPath:filePath];
NSString *urlString = [url absoluteString];
NSString *encodedString=[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *webURL = [NSURL URLWithString:encodedString];
NSURLRequest *request = [NSURLRequest requestWithURL:webURL];
[self.pdfWeb loadRequest:request];
這裏self.pdfWeb
是我的WebView和文件已經在文件的目錄,但網頁流量無法加載文件。
它沒有顯示出.. –