I've read tons of stuff on this and while most seems to be in regards to the non-storyboard approach, I thought I had pieced bits together and figured it out. However, the following code does not result in my popover being dismissed. The dismissPopoverButtonPressed button in the Popover executes but a breakpoint in the dismissPopover method in the delegate never hits. Would very much appreciate someone casting an eye over the code to spot mistakes.
Thanks
In the following, NewGameViewController contains a UIButton. Pressing this results in the Popover Segue and subsequent display of the popover containing the PopViewController UIView.
NewGameViewController.h
#import "PopViewController.h"
@interface NewGameViewController: UIViewController <DismissPopoverDelegate>
{
UIPopoverController *popover;
}
NewGameViewController.m
@implementation NewGameViewController
-(void)prepareForSegue:(UIStoryboardPopoverSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"popoverSegue"])
{
popover = [(UIStoryboardPopoverSegue *)segue popoverController];
// getting warning: Assigning to 'id<UIPopoverControllerDelegate>' from incompatible type 'NewGameViewController *const__strong'
//popover.delegate = self;
}
}
-(void)dismissPopover
{
[popover dismissPopoverAnimated:YES];
}
PopViewController.h
@protocol DismissPopoverDelegate <NSObject>
-(void) dismissPopover;
@end
@interface PopViewController: UIViewController
{
__unsafe_unretained id<DismissPopoverDelegate> delegate;
}
@property (nonatomic, assign) id<DismissPopoverDelegate> delegate;
-(IBAction)dismissPopoverButtonPressed:(id)sender;
@end
PopViewController.m
#import "NewGameViewController.h"
@implementation PopViewController
@synthesize delegate;
-(IBAction)dismissPopoverButtonPressed:(id)sender
{
[self.delegate dismissPopover];
}