【发布时间】:2011-08-02 04:34:34
【问题描述】:
我正在尝试下载网页 (html),然后在 UIWebView 中显示已下载的本地 html。
这是我尝试过的-
NSString *stringURL = @"url to file";
NSURL *url = [NSURL URLWithString:stringURL];
NSData *urlData = [NSData dataWithContentsOfURL:url];
if ( urlData )
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"index.html"];
[urlData writeToFile:filePath atomically:YES];
}
//Load the request in the UIWebView.
[web loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]]; // Do any additional setup after loading the view from its nib.
但这会产生“SIGABRT”错误。
不太确定我做错了什么?
任何帮助将不胜感激。谢谢!
【问题讨论】:
-
查看调试器输出。可能有消息。
标签: iphone xcode ios ios4 uiwebview