The functionality I want is this:
I have a set of URLs that I want to load into an existing UIWebView without pushing in a new ViewController. I just want the webView to reload with no animation or sliding.
Right now, this is my implementation in ViewController:
@synthesize webView;
@synthesize requestObj;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
//I show a spinner while it is loading. This is done in webViewDidStartLoad:
viewLoading = YES;
//this is landing URL, so I draw some buttons in viewDidLoad
home = YES;
//I load this request into my webView in viewDidLoad
requestObj = [NSURLRequest requestWithURL:[NSURL URLWithString:myURL]];
}
return self;
}
Then, somewhere down in the ViewController, if someone presses a specific URL in my sliding menu I call:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:newUrl]];
[webView loadRequest:request];
I cannot figure out how to load this new URL into the exciting webView without a new version of ViewController being pushed into the stack. Every time it calls my initWithNibName: method in ViewController, but I can't figure out a good way to stop it from pushing itself on to the stack, and just update the webView.
I can use [self.navigationController setViewControllers:] to make a new ViewController and keep the controller from drawing the backButton, but it still sliding.
There must be an easy way to reload the webView that I am just not getting. Any suggestions?