gpt4 book ai didi

iphone - 如何在 UIWebView 中打开我的 documentDirectory(来 self 的 UITableView)文件?

转载 作者:行者123 更新时间:2023-11-28 23:10:35 24 4
gpt4 key购买 nike

我希望可以访问我的 iOS 文档目录中的文件(这些文件列在我的 UITableView 中),因此当点击时,UIWebView 会加载该文件(离线)。

我该怎么做?

最佳答案

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *pathForYourFile = [documentsDirectory stringByAppendingPathComponent:[filePathsArray objectAtIndex:indexPath.row]];

[yourWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:pathForYourFile ofType:@"html"]isDirectory:NO]]];

}

请参阅此文档以了解 UIWebView 支持的文件格式

http://developer.apple.com/library/ios/#qa/qa1630/_index.html

关于iphone - 如何在 UIWebView 中打开我的 documentDirectory(来 self 的 UITableView)文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8382005/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com