ASIHTTPRequest *request=[ASIDataService GET_Path:path completed:^(id JSON, NSString *stringData) {
//获取到html信息
//NSLog(@"jason%@,stringdata%@",JSON,stringData);
//修改html信息
NSString *htmlString=[stringData stringByReplacingOccurrencesOfString:@"http://s.fwxgx.com/jquery_mobile/jquery.mobile-1.4.5.min.css" withString:@"jquery.mobile-1.4.5.min.css"];
htmlString=[htmlString stringByReplacingOccurrencesOfString:@"http://s.fwxgx.com/jquery_mobile/jquery-1.11.1.min.js" withString:@"jquery-1.11.1.min.js"];
htmlString=[htmlString stringByReplacingOccurrencesOfString:@"http://s.fwxgx.com/jquery_mobile/jquery.mobile-1.4.5.min.js" withString:@"jquery.mobile-1.4.5.min.js"];
//htmlString=[stringData stringByReplacingOccurrencesOfString:@"/survey/save_train_survey" withString:@"http://gmsa.fwxgx.com/survey/save_train_survey"];
//写入本地文件
/*
NSString *successPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Success.text"];
NSArray *SuccessArray=@[[NSString stringWithFormat:@"%@/%@",filePath,name]];
NSDictionary *dic=@{@"Root":SuccessArray};
BOOL success = [dic writeToFile:successPath atomically:YES];
*/
NSLog(@"/n html%@",htmlString);
[webView loadHTMLString:htmlString baseURL:[NSURL fileURLWithPath:[ [NSBundle mainBundle] bundlePath]]];
[self.view addSubview:webView];
} failed:^(NSError *error) {
NSLog(@"数据失败");
}];JS文件只能手动放到copyResourc里面,不能作为可编译文件,另外由于html字符串过长,编译器不会全部显示
原文:http://8287272.blog.51cto.com/8277272/1659556