2

我不知道是否有人在使用这个开源库来替换 iPhone 的 UIPopovercontroller。

我正在尝试将 FPPopover 部署到我的项目中,一切正常,但问题是我无法将任何值返回给我的 ViewController。

我在 didSelectRowAtIndexPath 中尝试这个

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

但问题是 self.parentViewController 是(空)

我还有另一个问题,如何从 didSelectRowAtIndexPath 中解除 FPPopoverController。

4

1 回答 1

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!

于 2012-07-24T04:35:37.610 回答