我们可以从UIWebView打开pdf文件吗?
如果有人实施了这个,请帮助我.
任何代码段或任何网络链接都会有所帮助.
我有一个应用程序,我可以下载PDF并将其存储在iPhone中.它在iOS 7中完美运行(我目前在iOS 8上运行),在iOS 8中运行应用程序时,webView只保持空白.我不知道出了什么问题.
#import "ISJMMisalViewController.h"
#import "SWRevealViewController.h"
@implementation ISJMMisalViewController
@synthesize activityImageView;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
[self.webView addSubview:activityImageView];
[activityImageView startAnimating];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath]stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
NSString *filePath = [resourceDocPath stringByAppendingPathComponent:@"misalLocal.pdf"];
//Now create Request for the file that was saved in your documents folder
NSURL *url = [NSURL fileURLWithPath:filePath];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
dispatch_async(dispatch_get_main_queue(), ^{
[self.webView setUserInteractionEnabled:YES];
[self.webView setDelegate:self];
[self.webView loadRequest:requestObj];
[self.webView setScalesPageToFit:YES];
[activityImageView stopAnimating];
[activityImageView removeFromSuperview];
});
});
}
- (void)viewDidLoad …Run Code Online (Sandbox Code Playgroud)