通常情況下我們需要讀取word文檔链烈,在iOS中可以通過webView來讀取word文檔号坡,相當(dāng)簡單:
1.首先在viewDidLoad創(chuàng)建一個webView并調(diào)用方法
webView2 = [[UIWebView alloc]initWithFrame:CGRectMake(0, 20, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
///調(diào)用
[self loadDocument:@"現(xiàn)有的本地word文檔.docx" inView:webView2];
[self.view addSubview:webView2];
///自動適應(yīng)大小
webView2.scalesPageToFit = YES;
///關(guān)閉下拉刷新效果
webView2.scrollView.bounces = NO;
2.實現(xiàn)方法
-(void)loadDocument:(NSString *)documentName inView:(UIWebView *)webView
{
NSString *path = [[NSBundle mainBundle] pathForResource:documentName ofType:nil];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
}