【发布时间】:2013-09-18 22:52:12
【问题描述】:
我有一个 HTML 文件保存在这样的临时目录中:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentDirectory = NSTemporaryDirectory();
NSString *documentPath = [documentDirectory stringByAppendingPathComponent:@"mydocument.html"];
[fileManager createFileAtPath:documentPath contents:myHTMLDocumentData attributes:nil];
文档是在我的临时文件中创建的。之后,我想在 Safari 中打开此文档,但它不起作用:
NSURL *url = [NSURL fileURLWithPath:documentPath];
[[UIApplication sharedApplication] openURL:url];
屏幕上什么都没有发生,没有错误... 但是,如果我将“url”替换为@“http://google.fr”,Safari 将使用 google.fr 启动,我可以通过键入 url“file://localhost..../”来访问我的临时文件myHtmlDocument.html”在 Safari 中。
希望你能帮助我
【问题讨论】:
-
如果您的 iOS 设备有互联网连接,请将其放在网络上并打开它
标签: objective-c ios cocoa-touch safari