【问题标题】:Local html or pdf file in CocoaCocoa 中的本地 html 或 pdf 文件
【发布时间】:2012-06-30 21:11:19
【问题描述】:

我需要在 Cocoa 中打开一个本地(而不是在网络上)html 文件或 pdf 文件,而不是在 iOS 中。我可以找到很多使用 UIKit 的示例,但还没有找到完整的使用 WebKit 的代码思路。有人可以帮助我指出正确的方向或提供一些关于如何做到这一点的想法。

【问题讨论】:

  • 谢谢。这很有帮助,它推动了项目向前发展。使用 pdf 文件的设置似乎无法找到该文件。我会在另一篇文章中问这个问题。

标签: cocoa-touch cocoa


【解决方案1】:

我很欣赏关于这个问题的建议。 以下是我使用的代码

- (void)windowDidLoad
{
    [super windowDidLoad];

    NSString* filePath = [[NSBundle mainBundle]
                          pathForResource:@"myDocumentText"
                          ofType:@"pdf"]; 
    NSURL* fileURL = [NSURL fileURLWithPath:filePath];
    NSURLRequest* request = [NSURLRequest requestWithURL:fileURL];
    [[myWebView mainFrame] loadRequest:request];   

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-10
    • 1970-01-01
    • 2020-12-06
    • 2021-08-28
    相关资源
    最近更新 更多