I have two View Controllers: TableViewController (which is used as a modal view controller) and ToolbarController. In Interface Builder I have ToolbarView, which is controlled by the ToolbarController.
ToolbarView has an IBOutlet UIWebView that ToolbarController controls (uses buttons on a tool bar to switch pages in a webview).
What I need is the ability to have TableViewController to change the UIWebview in ToolbarView.
How can I accomplish this?
TableViewController.h:
#import <UIKit/UIKit.h>
#import "ToolbarController.h"
#import "MyAppDelegate.h"
@interface TableViewController : UITableViewController {
NSMutableArray *widgetList;
IBOutlet UIWebView *webView;
}
@property(nonatomic,retain) IBOutlet UIWebView *webView;
@end
TableViewController.m:
#import "TableViewController.h"
#import "MyAppDelegate.h"
#import "ToolbarController.h"
#import "TableView.h"
@implementation TableViewController
@synthesize webView;
//Lots of working code omitted
//didSelectRowAtIndex below should change the webView in ToolbarView to Google's homepage but does not.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *urlAddress=[NSString stringWithFormat:@"http://www.google.com"];
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
[self dismissModalViewControllerAnimated:YES];
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end