通常情况下我们需要读取word文档,在iOS中可以通过webView来读取word文档,相当简单:
1.首先在viewDidLoad创建一个webView并调用方法
webView2 = [[UIWebView alloc]initWithFrame:CGRectMake(0, 20, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
///调用
[self loadDocument:@"现有的本地word文档.docx" inView:webView2];
[self.view addSubview:webView2];
///自动适应大小
webView2.scalesPageToFit = YES;
///关闭下拉刷新效果
webView2.scrollView.bounces = NO;
2.实现方法
-(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];
}