I am writing an iPad app and am very new to objective C. I am currently trying to use a popover as a menu within a view controller. I understand how to set the popup up and have a tableview in it for a user to select an item from. However, I am not sure how to then pass the information back to the container view which holds the popover. didSelectRowAtIndexPath
will be called within the UITableViewController
which is presumably inside the popover view controller. Can anyone point me in the right direction for how to get this information back to the container?
Thanks in advance!
I'm also looking for the answer to this problem. I did solve it using NSNotification.
Here's how:
The View Controller that displays the popup should register to receive the notification:
// languageSetup is the function that will be called,
SPVWChangeLanguage
is a string that you will define in your popup view controllerI added this line in
viewDidAppear
Now in your popup view controller add this line when the user selects something in the table:
before dismissing the popup:
That's all. The selector
languageSetup
(in my case) will be called. Be sure to remove the notification when your view controller goes away:I do it in
viewWillDisappear
I think there must be an easier way. But at least, this one works for me.
You need to use delegate. It is very commonly used pattern in this situation. I have an answer to this SO similar question with an example. Let me know if you still are not clear afterward.
Well, I assume that the delegate of your
UIPopoverController
is your content view, if so, you can request theparentViewController
property from theUITableView
and then cast it to aUIPopoverController
to get it's delegate (in your case the delegate would be the container view).