2

i don't know if anyone is using this open source library for replacing UIPopovercontroller for an iPhone.

i'm trying to deploy the FPPopover into my project, everything is working like i want, but the problem is that i'm not able to return any value to my ViewController.

i'm trying this in didSelectRowAtIndexPath

myParentViewController *parentController =(myParentViewController*)self.parentViewController;

but the problem is that self.parentViewController is (null)

i have also another problem, how can i dismiss the FPPopoverController from within didSelectRowAtIndexPath.

JOM
  • 8,139
  • 6
  • 78
  • 111
Thomas_LEB
  • 239
  • 5
  • 12

1 Answers1

3

I dismissed the view by adding a popoverView property to the table view controller that is popping up (in this case ATableViewController), and then assigning the FPPopoverViewController to that property. Like this:

ATableViewController *aTableViewController = [[ATableViewController alloc] init]; 

FPPopoverController *aPopoverController = [[FPPopoverController alloc] initWithViewController:aTableViewController]; 

aPopoverController.delegate = aTableViewController;
aTableViewController.popoverView = aPopoverController;

Then in didSelectRowAtIndexPath of aTableViewController you can just call:

[self.popoverView dismissPopoverAnimated:YES];

If you are trying to return values to the "parent"...since the parentViewController property is null here, you can just make your own property for it (let's call it "parentView"). So when setting up the above you would use:

aTableViewController.parentView = self;

Then you can access any of the properties of the parentView and return values from the aTableViewController that popped up. A bit of a workaround, but that's what I did...hope it helps!

JAB
  • 3,165
  • 16
  • 29
  • Hey, Thanks for the info! After a cell is tapped, I'd like to dismiss the popover and fire a ModalView. Thanks to your answer, I got the popover to dismiss. To trigger a ModalView from the parentView, should I set up a delegate for the parentView and trigger it before dismissing popover? or [aTableViewController.parentView callModalViewMethod] should do? – user1107173 Sep 10 '13 at 03:15