我有这个代码来呈现一个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];
}
现在在didSelectRow
中调用FavoritesViewController
时,我希望解除弹出窗口。我尝试了[self dismissPopoverAnimated: YES];
,但这无法识别。
答案 0 :(得分:2)
您需要在FavoritesViewController中获取对popoverController的引用。在FavoritesViewController中设置popoverController属性,然后你应该能够在didSelectRow
方法中将其解除。