webView加载本地数据


[super viewDidLoad]; webview=[[UIWebView alloc] initWithFrame:self.view.bounds]; [self.view addSubview: webview]; [webview release]; // Do any additional setup after loading the view, typically from a nib.
//沙盒中读取文件
NSString *doc=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; doc=[doc stringByAppendingPathComponent:@"liuyan.html"]; NSLog(@"%@",doc); NSURL *url=[NSURL fileURLWithPath:doc]; NSLog(@"%@",url); NSURLRequest *request=[NSURLRequest requestWithURL:url]; [webview loadRequest:request]; }

posted @ 2015-09-21 16:41  zero_zql  阅读(342)  评论(0编辑  收藏  举报