donparalias donparalias - 3 months ago 10
iOS Question

UIWebView doesnt load URL , iOS

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

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]; 
}
Comments