【问题标题】:Display HTML Pages from Documents Directory in UIWebView在 UIWebView 中显示文档目录中的 HTML 页面
【发布时间】:2012-02-01 07:44:18
【问题描述】:

我正在解压缩 EPUB 文件并将其存储在文件夹内的 Documents 目录中。

现在我想在 UIWebView 中显示所有 HTML 页面,并在 tableView 中显示所有 HTML 页面名称。

例如,如果我有Introduction_1.html,那么我想在表格视图中显示“Introduction_1”等等。

提前致谢

【问题讨论】:

    标签: iphone ios ios4 xcode4.2


    【解决方案1】:

    这里的documentDirectory 代表文档目录的路径。如果您的文件位于文档目录以外的位置,显然您可以将路径放在那里。

      NSArray *dirContents = [[NSFileManager defaultManager] directoryContentsAtPath:documentDirectory];
        NSString *strFinalPath = [dirContents stringByAppendingPathComponent:@"OEBPS"];
        for (NSString *tString in strFinalPath) 
        {
            if ([tString hasSuffix:@".html"])
            {    
                NSLog(@"File name -> %@",tString);    
            }
        }
    

    希望对您有所帮助。

    【讨论】:

    • 谢谢你的回复,我会试试这个。
    • 我的路径在文件路径变量中,并且在该路径中我有一个名为“OEBPS”的文件夹,您能告诉我现在如何给出路径。
    • 如果你没有得到,请把 NSLog(@"filepath -> %@",filepath);并在此处打印路径,以便我了解您说的是哪条路径
    • 非常感谢你的回复,我看不到你的回复,我现在去看看。
    猜你喜欢
    • 2012-10-10
    • 1970-01-01
    • 1970-01-01
    • 2020-02-19
    • 1970-01-01
    • 2012-02-29
    • 1970-01-01
    • 2019-04-08
    • 2011-01-17
    相关资源
    最近更新 更多