Reputation: 6431
I have a viewController called mainViewController that contains a UIWebView called "myWebView". mainViewController presents a popover viewController called subViewController. In subViewController I have a button that is supposed to reload the myWebView. Doing something like this:
mainViewController *vc = [[mainViewController alloc] init];
does not work because it creates another instance of mainViewController. How can I reload the myWebView in the mainViewController that is currently presenting the popover window.
Upvotes: 0
Views: 317
Reputation: 2272
Unless I misunderstood your question, this seems fairly easy to accoumplish. I suppose you could sent a notification from UIPopoverController. First in your main view controller in viewWillAppear add self as observer:
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(reloadMyWebView:) name:@"reloadWebView" object:nil];
You have to implement method on your main view controller that will do actual reloading, this would be
- (void)realoadMyWebView:(NSNotification *)notification
make sure to remove yourself as a observer in viewWillDisappear
[[NSNotificationCenter defaultCenter]removeObserver:self];
then you can post a notification from you popover controller
[[NSNotificationCenter defaultCenter]postNotificationName:@"reloadWebView" object:nil userInfo:nil];
Upvotes: 1