Displaying ppt, doc, and xls in UIWebView doesn't work but pdf does

前端 未结 5 2110
感动是毒
感动是毒 2020-12-08 17:19

It looks like a few people on stackoverflow get this to work but their code isn\'t posted. I\'m using

[web loadData:data MIMEType:MIMEType textEncodingName         


        
5条回答
  •  时光说笑
    2020-12-08 17:46

    Have you tried using the following documented method?:

    -(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];
    }
    
    // Calling -loadDocument:inView:
    
    [self loadDocument:@"mydocument.rtfd.zip" inView:self.myWebview];
    

    It works for these in iPhone OS 2.2.1: Excel (.xls) Keynote (.key.zip) Numbers (.numbers.zip) Pages (.pages.zip) PDF (.pdf) Powerpoint (.ppt) Word (.doc)

    iPhone OS 3.0 supports these additional document types: Rich Text Format (.rtf) Rich Text Format Directory (.rtfd.zip) Keynote '09 (.key) Numbers '09 (.numbers) Pages '09 (.pages)

提交回复
热议问题