开发者

how to get a web page displayed on my uiwebview in objective -c

开发者 https://www.devze.com 2023-01-07 08:12 出处:网络
I am trying to display a web page in UIWebView so that when i click a button the webpage should be displayed in uiWebview.How could this be possible Can anybody help in solvin开发者_开发问答g this or

I am trying to display a web page in UIWebView so that when i click a button the webpage should be displayed in uiWebview.How could this be possible Can anybody help in solvin开发者_开发问答g this or give me some hint


You should have a look at the documentation for UIWebView.

There are two ways of doing this. The method you choose depends on where the data is coming from. If you're loading the data from a string, use:

NSURL* base = [NSURL URLWithString: @"http://..."];
[myWebView loadHTMLString: @"some html here" baseURL: base];

When loading HTML from a string the UIWebView needs to know the base URL for any relative URLs within the document, hence the baseURL: parameter.

If the data is accessible via a URL, use:

NSURL* url = [NSURL URLWithString: @"http://..."];
NSURLRequest* request = [NSURLRequest requestWithURL: url];
[myWebView loadRequest: request];
0

精彩评论

暂无评论...
验证码 换一张
取 消