I'm working on an app that uses a UIWebView to display its help files. The webView lives in it's own view, DocViewController...when its called the
- (void)viewDidLoad {
method uses
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource:docPage ofType:@"html"]isDirectory:NO]]];
to load the proper doc page. However, once the first page is loaded, the view becomes static and new pages aren't loaded when the docPage changes and the view is toggled. Is there a way to clear the webView so new pages load when requested?
Edit:
The first answer is confusing to me. As is the routine below works. It's just that it only works once. After the view is loaded the first time it does not change when this view is toggled on again and the requested html page is different. The view always displays the first html page requested and will not load new requests.
- (void)viewDidLoad {
docPage = [NSString stringWithFormat: @"%d", hexpage];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[NSBundle mainBundle] pathForResource:docPage ofType:@"html"]isDirectory:NO]]];
}
viewDidLoad
is only called once, unless the view is released and needs to be reloaded. This occurs usually only when the view controller receives a low memory warning. Instead ofviewDidLoad
, try putting that code inviewWillAppear:
, which gets called every time the view will show on the screen.Try using
passing an NSURL object to the dir that contains your HTML as baseURL and loading the HTML string with something like
Edit: Also, make sure that your hyperlinks are not trying to open in a new window with something like target="_blank", your webview will not open those