我们可以使用UIWebview使用https URL打开pdf

时间:2013-08-23 10:01:41

标签: iphone objective-c xcode https

我正在制作一个应用程序,其中我的应用程序需要使用https URLS.I想要在视图(或)UIWebview中使用https url显示PDF文件。我怎么做?请解释一下......提前致谢。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

NSError *error;

DisplayPdfViewController *pdf=[[DisplayPdfViewController alloc]init];

[self.navigationController pushViewController:pdf animated:YES];

if (indexPath.row==0) 

{

NSURL *url=[NSURL URLWithString:@"https:sampleurl"];

 NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];

[ NSURLConnection sendSynchronousRequest: urlRequest returningResponse: nil error: &error ];

NSURLRequest *request=[NSURLRequest requestWithURL:url];

[pdf.webView loadRequest:request];

//  pdf.title=[arrayList objectAtIndex:indexPath.row];

}

 else if (indexPath.row==1)

{

NSURL *url=[NSURL URLWithString:@"https: some sample url"];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];

[ NSURLConnection sendSynchronousRequest: urlRequest returningResponse: nil error: &error ];

 NSURLRequest *request=[NSURLRequest requestWithURL:url];

 [pdf.webView loadRequest:request];

 //  pdf.title=[arrayList objectAtIndex:indexPath.row];

 }

else if (indexPath.row==2)

{

 NSURL *url=[NSURL URLWithString:@"https: some sample url"];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];

 [ NSURLConnection sendSynchronousRequest: urlRequest returningResponse: nil error: &error ];

NSURLRequest *request=[NSURLRequest requestWithURL:url];

 [pdf.webView loadRequest:request];

//   pdf.title=[arrayList objectAtIndex:indexPath.row];

}


else if (indexPath.row==3)

{

NSURL *url=[NSURL URLWithString:@"https:some sample url"];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];

[ NSURLConnection sendSynchronousRequest: urlRequest returningResponse: nil error: &error ];

 NSURLRequest *request=[NSURLRequest requestWithURL:url];

[pdf.webView loadRequest:request];

// pdf.title=[arrayList objectAtIndex:indexPath.row];

 }

}

1 个答案:

答案 0 :(得分:0)

您需要手动下载网页,并使用loadData:MIMEType:textEncodingName:baseURL: