Zhen
Zhen

Reputation: 12431

Access Parent View Controller from tableViewController in popover view

I am trying to implement a popover view in a tableview controller. My intention is for the user to select an option from the table list as shown below.

enter image description here

Note that my popover view actually displays the data from a separate table view controller. I am creating the popover view controller via the following initialization method

self.popOverViewController = [[UIPopoverController alloc]initWithContentViewController:optionsTableViewController];

After the user selects an option for example "Hottest All Time", the control should be passed from the tableview Controller (in the popover view) back to the MAIN table view controller (parent view) so as to trigger a table reloadData method.

Query: Is there a way to return the control from the tableview controller in the popover controller back to the MAIN tableview controller? Do I have to use a delegate method to do this?

Upvotes: 1

Views: 2091

Answers (1)

Tommy
Tommy

Reputation: 100632

The two approaches I've seen are roughly the standard sort of fare:

  • create a delegate protocol for the class type of optionsTableViewController, have the controller that creates the popover implement it and set itself as the delegate when issuing the popover
  • use the NSNotificationCenter (which actually fits the intended purpose of the thing if you've a one-to-many message, as may be the case if you've a popover with a setting that affects a bunch of different controllers and you don't really care which is visible when the user requests the popover)

Upvotes: 4

Related Questions