在向UIWebView添加约束之前,我的应用程序正常工作。但是,有一个错误:
DiskImageCache: Could not resolve the absolute path of the old directory.
该应用仍然有效并显示pdf文件。添加一些约束后,它将不会显示pdf文件(它显示为空白),并且错误代码仍然存在。
以下是一些图片:
PIC 1:
PIC 2:
这是我的代码:
{
NSString* tutorialView = [NSString stringWithFormat:@"Chapter %i",tutorialNumber];
NSURL *pathToView = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:tutorialView ofType:@"pdf"]];
[_webView2 loadRequest:[NSURLRequest requestWithURL:pathToView]];
}
有没有更好的方法来查看PDF文件?我是iOS编程的新手。抱歉愚蠢的问题
答案 0 :(得分:0)
尝试以下操作。它与我完美搭配:)
UIWebView *pdf = [[UIWebView alloc] initWithFrame:CGM(0,0, self.view.frame.size.width, self.view.frame.size.height)];
NSString *path = [[NSBundle mainBundle] pathForResource:@"Name Of PDF FIle" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
pdf.scalesPageToFit = YES;
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];<br>
[pdf loadRequest:request];
[self.view addSubview:pdf];