【问题标题】:Accessing .html file in my Supporting Files directory on iPhone在 iPhone 上的 Supporting Files 目录中访问 .html 文件
【发布时间】:2012-02-07 18:52:08
【问题描述】:

我试图显示格式化文本并在此处对 SO 进行了一些研究,并且 ppl 说用 CG 绘制它或使用 html 并将其扔到 UIWebView 中。由于 UIWebView 是更简单的选择,我将文档格式化为 .html 并将其放入我的文件夹中,如下所示:

Supporting Files/Data/Template.html

如何访问此文件以在 UIWebView 中显示?

我知道我可以通过以下方式获取我的文件:

- (NSURL *)applicationDocumentsDirectory {
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

但在那之后,我被困住了。我不确定如何访问我的 Template.html。谢谢

【问题讨论】:

    标签: iphone nsfilemanager


    【解决方案1】:

    假设您已经拥有离线 template.html 文件的 NSURL。

    NSURLRequest * offlineRequest = [NSURLRequest requestWithURL:offlineURL];
    UIWebView * webview = [[[UIWebView alloc] init] autorelease];
    [webview loadRequest:offlineRequest];
    

    【讨论】:

    • 不,我没有包含在我的应用程序中的 template.html 文件的 NSURL。那是我不知道该怎么做的部分。
    • 也许这会有所帮助link
    猜你喜欢
    • 1970-01-01
    • 2011-05-20
    • 2012-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-19
    • 1970-01-01
    • 2011-07-26
    相关资源
    最近更新 更多