首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

iphone之打开pdf、doc、xls资料用UIWebView

2013-02-24 
iphone之打开pdf、doc、xls文件用UIWebView//文件名字及类型NSString *path[[NSBundle mainBundle]pathForR

iphone之打开pdf、doc、xls文件用UIWebView

//文件名字及类型    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];

热点排行