I am trying to open a webpage on the UIWebView - iphone

I am trying to open a webpage on the UIWebView which is secured. I am getting that error message also. But if i try to open it in safari it is giving an alert and i can continue from there forcefully. How can i implement that using UIWebView
Thanks in advance

I am not clear with your question but i understood something like you want to load a web page in UIWebView some of the snippet may use for you
UIWebView *loacalWebView=[[uiwebView alloc]initwithFrame:self.view.frame];
loacalWebView.delegate=self;
NSString *urlAddress = #"http://www.google.co.in";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[loacalWebView loadRequest:requestObj];

Related

UIWebView back button not getting enabled

In my application I have a UIWebView in which I need to add browser like functionality(user can goBack,Forward or reload the page). To achieve this I have used the code for this tutorial.
In my code I have only one change in viewDidLoad:
I am loading data from a local html file like this:
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:#"File name" ofType:#"html" inDirectory:NO];
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
[self.webView loadData:htmlData MIMEType:#"text/html" textEncodingName:#"UTF-8" baseURL:[NSURL URLWithString:#""]];
instead of:
NSURL* url = [NSURL URLWithString:#"http://iosdeveloperzone.com"];
NSURLRequest* request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
After loading initial html file if I am making any click on that page than the back button should get enabled, instead of its getting enabled after second url click and so that I am not able to go back to the original home page.
Please help me with this.
Thanks.
I got an answer. It's because you load data into the webView without loadRequest. If you load data into webView as a string, then it won't have any url to go back or load the old page. So it won't store the data you given to the webView. For that, you need to provide the url as like this.
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"File name" ofType:#"html"] isDirectory:NO]]];

how to show rss feed url in UIWebView in iphone sdk?

I am trying to display url in UIWebView but I can not display, webview just call the fail with error method. My url is this "http://www.tekniknoktamarket.com/index.php?route=feed/google_base",
So please help me how to display this url in UIWebView *?*
In order to have a UIWebView download and display the content from a URL, you need to go through a couple of layers of abstraction, the first being an instance of NSURL, which contains your URL string. Then, you hand the NSURL to an instance of NSURLRequest. Finally, you hand the NSURLRequest to the webView. It all looks something like this:
NSURL *url = [NSURL URLWithString:#"www.your-url.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[yourWebView loadRequest:request];
That should do it.
This is the code loading a URL into a webview:
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.theurl.com"]]];
If you're using this code and are encountering any problems, please provide the code you were using and the exact error

how to pass value through NSURL

i was trying to pass value to a native html page from my web view application
I try
url=[NSString stringWithFormat:#"%#?bob=123&frank=321&tom=213",url];
but when i build and debugging program, application crashes showing “EXC_BAD_ACCESS”
Please help me if anyone knows how to do this.
The UIWebView class only supports loading of URLs using the NSURLRequest class. To do what you want to do, you'll need this:
NSURL *url = [NSURL URLWithString: [NSString stringWithFormat:#"%#?bob=123&frank=321&tom=213", base]];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[webView loadRequest:req];

Iphone Open With in a UIWebView

is it possible to show a PDF in a UIWebView with the option Open in Books and Open With at the top of the WebView? I don't know how to do that.
Thanks
Put a UIDocumentInteractionController on top of the web view, it will allow the user to open the pdf in iBooks.
NSString * path = [[NSBundle mainBundle] pathforResource:#"ResourceName" ofType:#"pdf"] ;
or path can be any http url too.
NSURL * url = [NSURL fileURLWithPath:path];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
UIWebView * webView = ....;
[webView loadRequest:request];
This should show the pdf in webview. But seems you are asking to open the pdf in some other app, which part I didn't understand completely. Can you explain?

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

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 solving 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];