使用 AsiHttpRequest 和 UIWebView 查看文档(pdf、doc、xls)的最佳方式是什么???我尝试了以下操作,但 UIWebView 正在显示 html:
NSString * baseURL = @"http://xxxxxx/open-api/v1/";
NSString * itemRef = @"item/133/attachment/test.pdf";
NSString *urlString = [NSString stringWithFormat:@"%@%@", baseURL, itemRef];
NSURL *url = [NSURL URLWithString:urlString];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setUsername:@"xx"];
[request setPassword:@"xx"];
[request startSynchronous];
NSError *error = [request error];
if (!error) {
[self.webView loadHTMLString:[request responseString] baseURL: [request url]];
}
else {
NSLog(@"Error: %@", error );
}
AsiHttpRequest 是设置基本身份验证和标头值所必需的...谢谢!