美文网首页
使用WKWebView加载本地PDF

使用WKWebView加载本地PDF

作者: 隔墙送来秋千影 | 来源:发表于2020-05-22 15:43 被阅读0次

    使用WKWebView加载本地pdf

    - (void)viewDidLoad {
        [super viewDidLoad];
        WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.bounds];
        NSURL *pdfUrl = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"hello" ofType:@"pdf"]];
    //    NSURL *pdfUrl = [NSURL URLWithString:@"http://www.taobao.com"];
        NSURLRequest *request = [NSURLRequest requestWithURL:pdfUrl];
        [webView loadRequest:request];
        [self.view addSubview:webView];
    }
    

    问题来了
    加载网络链接的时候正常加载;
    但是、
    加载本地pdf的时候为空白页、
    控制台log输出:

    2020-05-22 15:19:12.172698+0800 appDemo[23683:1471101] WF: === Starting WebFilter logging for process 学谷智能
    2020-05-22 15:19:12.172771+0800 appDemo[23683:1471101] WF: _userSettingsForUser mobile: {
        filterBlacklist =     (
        );
        filterWhitelist =     (
        );
        restrictWeb = 1;
        useContentFilter = 0;
        useContentFilterOverrides = 0;
        whitelistEnabled = 0;
    }
    2020-05-22 15:19:12.172812+0800 appDemo[23683:1471101] WF: _WebFilterIsActive returning: NO
    

    然后很纠结、再然后就沙雕了

    //既然是加载本地的,那就是用fileURLWithPath啊
    NSURL *pdfUrl = [NSURL fileURLWithPath:path];
    
    //谁让我用了
    [NSURL URLWithString:];
    

    GG

    相关文章

      网友评论

          本文标题:使用WKWebView加载本地PDF

          本文链接:https://www.haomeiwen.com/subject/nhwqahtx.html