【问题标题】:Load text+pdf file in uiwebview在 uiwebview 中加载 text+pdf 文件
【发布时间】:2014-11-05 07:02:10
【问题描述】:

我想一次在 web 视图中显示一些文本和 pdf 文件。

有没有可能..

我尝试过使用

NSString *htmlString = [NSString stringWithFormat:@"<p>some text which i need to show above pdf</p><img src=\"file://%@\">",@"FR.pdf"];
NSString *bundleP = [[NSBundle mainBundle] resourcePath];
NSURL *fileURL = [NSURL fileURLWithPath:bundleP];
[pdfWebView loadHTMLString:htmlString baseURL:fileURL];

这显示文本,并且只显示pdf文件的第一页,..

提前致谢

【问题讨论】:

    标签: ios pdf uiwebview


    【解决方案1】:

    使用另一种方式加载 pdf 并在 webView 上方添加 UILabel 以显示文本。如您所见,pdf 被视为image,因此只显示一页。

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"FR" ofType:@"pdf"];
    NSURL *filePathURL = [NSURL fileURLWithPath:filePath];
    [self.webView loadRequest:[NSURLRequest requestWithURL:filePathURL]];
    

    【讨论】:

    • 实际上,客户不希望我使用标签。由于内存分配问题
    • 我不认为这样做会导致内存问题,反正这是你的客户。
    猜你喜欢
    • 1970-01-01
    • 2013-09-10
    • 1970-01-01
    • 1970-01-01
    • 2015-12-08
    • 2018-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多