UIWebView doesnt load URL , iOS

donparalias picture donparalias · Mar 25, 2013 · Viewed 24.8k times · Source

I am trying to load a URL when my app starts.

I dragged an UIWebView Object , on my .nib , i created a property outlet , i connected it to the webview and in my view controller i place the following code :

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSString *fullURL = @"http://google.com";
    NSURL *url = [NSURL URLWithString:fullURL];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];
}

However i just get a black screen on the device , like theres no view at all. Any idea?

Answer

Premsuraj picture Premsuraj · Mar 25, 2013

This is the code I'm using in my application

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSURL *websiteUrl = [NSURL URLWithString:@"http://www.google.com"];
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:websiteUrl];
    [myWebView loadRequest:urlRequest]; 
}