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?
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];
}
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"]]];
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With