UIWebView not loading URL
Posted
by jerincbus
on Stack Overflow
See other posts from Stack Overflow
or by jerincbus
Published on 2010-04-20T20:40:22Z
Indexed on
2010/04/20
20:43 UTC
Read the original article
Hit count: 575
I'm having trouble getting a UIWebView to load a URL that I'm sending to it. Before I get into my code I was wondering if URL has to start with "http://" or can it start with "www."?
I'm using an IBAction to push a UIView on to the stack:
(IBAction)goToWebView {
WebViewController *webController = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]];
//set the strings
webController.webTitle = [self Title];
webController.webURL = [self website];
//Push the new view on the stack
[[self navigationController] pushViewController:webController animated:YES];
[webController release];
webController = nil;
}
Then here is my WebViewController.h file:
@interface WebViewController : UIViewController {
IBOutlet UIWebView *webView;
NSString *webTitle;
NSString *webURL;
}
@property (nonatomic, retain) IBOutlet UIWebView *webView;
@property (nonatomic, retain) NSString *webTitle;
@property (nonatomic, retain) NSString *webURL; here
And my WebViewController.m file:
- (void)viewDidLoad {
[super viewDidLoad];
NSString *urlAddress = webURL;
//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];
}
© Stack Overflow or respective owner