可以改一下
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/Index/getPhotoes/device_id/%@", HTTP_HOST, [LKDevice getDeviceId]]]];
_queue = [[NSOperationQueue alloc] init];
[NSURLConnection sendAsynchronousRequest:request queue:_queue completionHandler:^(NSURLResponse *response, NSData *data,NSError *connectionError) {
// 需要將二進(jìn)制數(shù)據(jù)轉(zhuǎn)換成html的字符串
// 注:NSData轉(zhuǎn)為字符串沒(méi)有類(lèi)方法
// ENCODING字符編碼,如果沒(méi)有特殊要求,在iOS中統(tǒng)一使用UTF8
NSString *html = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", html);
//用webView加載html
/**
baseURL:http://www.baidu.com
使用的時(shí)候URL就可以只傳后半部分就行
*/
dispatch_async(dispatch_get_main_queue(), ^{
[self.webView loadHTMLString:html baseURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/Index/getPhotoes/device_id/%@", HTTP_HOST, [LKDevice getDeviceId]]]];
});
}];