将HTTPS://网站加载到UIWebView的最佳方式?

时间:2010-05-25 15:59:22

标签: iphone https uiwebview

使用https将网站加载到网页视图的最佳方法是什么? 有一个简单的方法吗?

由于

菲利普

1 个答案:

答案 0 :(得分:1)

我所知道的最简单的方法是......

NSString *urlAddress = @"https://www.google.com";

//Create a URL object from the string 'urlAddress'
NSURL *url = [NSURL URLWithString:urlAddress];

//Create a URL Request Object from NSURL object 'url'
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

//Load the NSURLRequest object 'requestObj' in the UIWebView.
[webView loadRequest:requestObj];

当然,你可以把它浓缩成一个单行......

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.google.com"]]];