这是问题,我使用 AFNetwoking 获取返回的页面 html。我可以看到 responseObject 是一个 html 页面。这是我使用的代码。
NSURL *url = [NSURL URLWithString:@"https://graph.z.qq.com/moc2/authorize"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setValue:@"code" forKey:@"response_type"];
[params setValue:@"100266567" forKey:@"client_id"];
[params setValue:@"http://www.qq.com" forKey:@"redirect_uri"];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"GET" path:@"https://graph.z.qq.com/moc2/authorize" parameters:params];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
__block NSData *data = [[NSData alloc] init];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject){
data = responseObject;
NSLog(@"Response: %@", [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]) ;
} failure:^(AFHTTPRequestOperation *operation, NSError *error){
NSLog(@"Error: %@", error);
}];
[operation start];
现在我想将 responseObject 加载到 uiwebview 中。我尝试了 loadHTMLString ,但没有用。
[webView loadHTMLString:[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] baseURL:url ];
有人对此有任何想法吗?