I am trying to load an HTML file stored locally on the apps documents directory using the method shown below. It ain't workin. What am I doing wrong?
NSLog(#"Loading Saved Copy!");
urlAddress = [[self documentsDirectory] stringByAppendingPathComponent:#"/Profile/profile.html"];
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
Use +[NSURL fileURLWithPath:isDirectory:] instead.
Related
I have an NSString called status and I am trying to pass that variable to load a webView. The app is crashing here, but I don't know what I am doing wrong? Does anyone see anything wrong with the request?
[webView loadRequest:[NSURLRequest requestWithURL:[NSString
stringWithFormat:#"http://www.website.com/page.php?status=%#", status]]];
requestWithURL accepts NSURL, So you need to convert string into NSURL
Try this,
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://www.website.com/page.php?status=%#", status]]]];
+[NSURLRequest requestWithURL:] is expecting you to give it an NSURL object. You're giving it an NSString. Don't do that. :)
NSString *urlAddress = [NSString stringWithFormat:#"http://www.website.com/page.php?status=%#", status];
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
Use this:
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://www.website.com/page.php?status=%#", status]]]];
i am making an iPad application,
i want to load 2 webPage on single UIWebView one after another,
1st webpage should come when i load my application,and 2nd webpage should come on click of cell of tableView,
so,inside my didLoad method i am writing this (1st webpage),
NSString *urlAddress = #”http://www.google.com”;
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
it works fine..
but on the same page on same webview on click of cell of tableView i want to load another page,(2nd webpage)
i written code for the same, when i click on cell of tableView graph is not displaying,
do i need to clear webpage or reload webpage something like that ?
Help Me Guys, Thanx in Advance !!
call this method,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *urlAddress = #”http://www.google.com”;
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
}
I see from your comment that you use a wrong URL format for the second request:
NSString *urlAddress1 = #”yahoo.com”; //Create a URL object.
NSURL *url1 = [NSURL URLWithString:urlAddress1]; //URL Requst Object
NSURLRequest *requestObj1 = [NSURLRequest requestWithURL:url1]; //Load the request in the
UIWebView. [webView loadRequest:requestObj1];
The URL has to begin with
http://
Otherwise it won't work.
I'm new to Objective-C.
I have made an application which redirects a string to a webView. I want that webView should load wikipedia and should search the contents present in that string.
I have written like this...
NSString *urlString=[NSString stringWithFormat:#"http://en.wikipedia.org/wiki/Main_Page/search=%#",str1];
//[urlString stringBy];
NSLog(#"url %#",urlString);
NSURL *url=[NSURL URLWithString:urlString];
NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
[webView loadRequest:request];
NSString *urlAddress = #”http://www.google.com”;
// Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
// URL Request Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
// Load the request in the UIWebView.
[webView loadRequest:requestObj];
Good luck
How to use uiwebview to show some web page for url request? i dont know how to do it. who can tell me how to do it? has any opensource? thanks.
NSString *urlAddress = #"http://www.google.com";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
I have a ViewController and UIWebView created in Interface Builder in it. I fill webView with data like this:
NSString *urlAddress = self.artUrl;
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[self.webView loadRequest:requestObj];
How should I release content of this webView in didReceiveMemoryWarning?
Thanks
You either release the whole web view (if it is off-screen for example), or nothing at all. If you really need to release the contents, load a blank page.