How To Dismiss UIPopover At DidSelectRow?
I have this code to present a popover:
- (UIPopoverController *)favoritesPopover
{
if (!favoritesPopover)
{
FavoritesViewController *fvc = [[FavoritesViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:fvc];
[fvc release];
favoritesPopover = [[UIPopoverController alloc] initWithContentViewController:navController];
[navController release];
favoritesPopover.delegate = self;
}
return favoritesPopover;
}
- (IBAction)toggleFavorites:(id)sender
{
if (!self.favoritesPopover.popoverVisible)
[self.favoritesPopoverpresentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
else
[self.favoritesPopover dismissPopoverAnimated:YES];
}
Now when didSelectRow
is called in FavoritesViewController
, I want the popover to be dismissed. I tried [s开发者_运维知识库elf dismissPopoverAnimated: YES];
but that isn't recognized.
You need to get a reference to the popoverController in your FavoritesViewController. Setup a popoverController property in FavoritesViewController and then you should be able to dismiss it in the didSelectRow
method.
精彩评论