![](/img/trans.png)
[英]Getting application crash during opening a local csv file with size more than 2Mb on UIWebView in device
[英]Getting application crash during opening a local pdf file on UIWebView
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSString *path = [[NSBundle mainBundle] pathForResource:@"About" ofType: @"pdf"];
NSLog(@"%@", path);
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[_webView loadRequest:request];
}
只需在Web視圖中使用以下代碼即可打開PDF
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"About" ofType:@"pdf"];
[self.webVctr loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];
並查看PDF是否存在?
這個想法可能會對你有所幫助
快樂編碼..
嘗試這個:
在里面
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];
NSString *path = [[NSBundle mainBundle] pathForResource:@"About" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];
[self.view addSubview:webView];
[webView release];
這是與Web視圖上的pdf加載無關的其他一些問題。 我交叉檢查並找到了崩潰的實際原因。 無論如何,謝謝你的幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.