App中文档的引入
目的:将pdf,docx,url连接,html文件导入到app的某个板块中
实现方式:利用UIWebView
使用UIWebView首先创建一个UIWebView的对象,取名为wbView。使用UIWebView的方便之处就在于不需要额外的代码就可实现程序对所导入文档的缩放功能。
代码:
/**
* Loading PDF File
*/
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = @"......";
/**
* Loading Files in UIwebview
*
* 1. Load url
* NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL: *[NSURL URLWithString:@"http://"]];
* [self.viewAgenda loadRequest: request];
*
* 2. Load html
* NSURL *url = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html"];
* [self.viewAgenda loadRequest:[NSURLRequest requestWithURL:url]];
*
* 3. Load docx
* NSURL *url = [[NSBundle mainBundle] URLForResource:@"sampleWord" withExtension:@"docx"];
* [self.viewAgenda laodRequest:[NSURLRequest requestWithURL:url]];
*/
NSURL *url = [[NSBundle mainBundle] URLForResource:@"File Name" withExtension:@"pdf"];
[self.wbView loadRequest:[NSURLRequest requestWithURL:url]];
}