http://www.th7.cn/Program/IOS/201303/128231.shtml
iphone之打开pdf、doc、xls文件用UIWebView
[cpp]
//文件名字及类型
NSString *path=[[NSBundle mainBundle]pathForResource:@"xls1" ofType:@"xls"];
//获取内容
NSData *data = [[NSData alloc]initWithContentsOfFile:path];
NSString *string = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@",string);
UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 55, 320, 300)];
webView.delegate = self;
webView.multipleTouchEnabled = YES;
webView.scalesPageToFit = YES;
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
[self.view addSubview:webView];
//文件名字及类型
NSString *path=[[NSBundle mainBundle]pathForResource:@"xls1" ofType:@"xls"];
//获取内容 www.2cto.com
NSData *data = [[NSData alloc]initWithContentsOfFile:path];
NSString *string = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@",string);
UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 55, 320, 300)];
webView.delegate = self;
webView.multipleTouchEnabled = YES;
webView.scalesPageToFit = YES;
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
[self.view addSubview:webView];
本文介绍如何在iOS应用中使用UIWebView加载并显示本地的xls、doc和pdf等文件,通过设置UIWebView的属性并加载NSURLRequest来实现。
1028

被折叠的 条评论
为什么被折叠?



