標籤:本地載入
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 *[email protected][[NSString stringWithFormat:@"%@/%@",filePath,name]]; NSDictionary *[email protected]{@"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字串過長,編譯器不會全部顯示
iosWebView載入本地js