Docx support in UIWebview(iOS)?

后端 未结 3 2122
离开以前
离开以前 2021-02-06 06:44

I have checked the official links for doc support, and it\'s clear that docx is not supported in UIWebview.

But, I also found out that some guys were able to open docx f

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-06 07:23

    Yes UIWebView supports the docx. Just tried loading a docx file from bundle and it seems working fine(in this example named "DOC1.docx")::

    NSString *path = [[NSBundle mainBundle] pathForResource:@"DOC1" ofType:@"docx"];
    NSURL *targetURL = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
    [mywebView loadRequest:request];
    

    and If you are trying to display a docx file residing on a server somewhere, you can simply load it to your web view directly:

    NSURL *targetURL = [NSURL URLWithString:@"http://www.central.wa.edu.au/Current_Students/JobsCareersandLeavingCentral/Documents/Resume%20Template.docx"];
    NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
    [mywebView loadRequest:request];
    

提交回复
热议问题