내 프로젝트에서는 PDFJS
라이브러리를 사용하고 있습니다. 나는 UIWebView
에 현지 pdf를 적재하고있다. 그러나 이것은 많은 RAM 메모리를 차지하며 한 시점에서 충돌을 일으 킵니다. 이를 피하려면 WKWebView
을 사용하고 싶습니다.iOS에서 pdf로 html 파일을로드하는 방법 WKWebView
UIWebview
에서
, I는 다음과 같이 사용하고, I는 상기 단편에 finalPath를 인쇄 할 때 콘솔 출력 WKWebView
, loadFileURL
에서 /var/containers/Bundle/Application/DF419672-CF14-4B60-BE4F-EC0AC07C23AE/WebviewPOC.app/PDFJS/web/viewer.html?file=/var/containers/Bundle/Application/DF419672-CF14-4B60-BE4F-EC0AC07C23AE/WebviewPOC.app/swift_tutorial.pdf#page=1
이다
UIWebView *uiWebview = [[UIWebView alloc] initWithFrame:self.frame];
[self addSubview:uiWebview];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"swift_tutorial" ofType:@"pdf"];
NSString *sPath = [[NSBundle mainBundle] pathForResource:@"viewer" ofType:@"html" inDirectory:@"PDFJS/web"];
NSString *finalPath = [NSString stringWithFormat:@"%@?file=%@#page=1",sPath,filePath];
self.urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:finalPath]];
[uiWebview loadRequest:self.urlRequest];
(self
은 UIView
의 서브 클래스를 의미) loadHTMLString
메서드는 로컬 html 파일이나 로컬 pdf 파일을로드하는 데 사용할 수 있습니다.이 파일은 정상적으로 작동합니다. 그러나 둘 다. 이 html 파일의 경우 로컬 PDF 경로와로드를 WKWebView
에 추가하는 방법은 무엇입니까?
도움을 주시면 감사하겠습니다.