Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 272
donparalias Avatar asked Mar 25 '13 09:03

donparalias


3 Answers

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]; 
}
like image 66
Premsuraj Avatar answered Sep 29 '22 22:09

Premsuraj


This is short one

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

        [myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];

}
like image 44
Sukeshj Avatar answered Sep 29 '22 21:09

Sukeshj


Restart your IOS simulator. It is really not evident, but check, at first, any site in Safari at IOS simulator. After restart of IOS simulator, my webView opened successfully both at simulator and device.

By Amit

like image 44
Devendra Avatar answered Sep 29 '22 23:09

Devendra