I wanted to play with UIPopupController, and I understood that I can t detect when my popover dismiss.
My steps:
1. Create example from XCode (File -> New Project - > Utilitiy Application)
2. Add to MainViewController.h UIPopoverControllerDelegate
#import "FlipsideViewController.h"
@interface MainViewController : UIViewController <FlipsideViewControllerDelegate,UIPopoverControllerDelegate>
@property (strong, nonatomic) UIPopoverController *flipsidePopoverController;
- (IBAction)showInfo:(id)sender;
@end
- In MainViewController:
- (IBAction)showInfo:(id)sender { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil]; controller.delegate = self; controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:controller animated:YES]; } else { if (!self.flipsidePopoverController) { FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil]; controller.delegate = self; self.flipsidePopoverController.delegate = self self.flipsidePopoverController = [[UIPopoverController alloc] initWithContentViewController:controller]; } if ([self.flipsidePopoverController isPopoverVisible]) { [self.flipsidePopoverController dismissPopoverAnimated:YES]; } else { [self.flipsidePopoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } } } -(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController { NSLog(@"OLOLO"); }
But when I tap somewhere, and popover disappears, there is no NSLog message in Console. What am I doing wrong?