I couldn't find a direct answer to this online, which surprised me, so hopefully Im not being stupid.
Basically I need a UIWebView in my 2nd view/viewcontroller, but I need to reference it in my first view controller to actually load the web page and go to the 2nd view.
This is in the first ViewController.m:
Code:
-(IBAction)goToSite {
secondview *second =[[secondview alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];
NSURL *url = [NSURL URLWithString:site];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[webview loadRequest:req];
}
So as you can see above, I need to reference the declared object "webview"(bold-faced), which in the last line of code tells the UIWebView to load, in my first ViewController, obviously this web view will be in the 2nd view.
So, how would I do that?
I tried #import on my secondview.h (where "webview" needs to be declared), into my ViewController.m, and apparently that doesn't work.
So how would I do this? Remember what I basically need to do is use the same object/variable in 2 view controllers.
Not sure if it's through the app delegate or not, but that didn't seem to work in my case.