Note that there are some explanatory texts on larger screens.

plurals
  1. POStoryboard: Dismissing Popover using delegate/protocol method
    primarykey
    data
    text
    <p>I've read <em>tons</em> 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.</p> <p>Thanks</p> <p>In the following, NewGameViewController contains a UIButton. Pressing this results in the Popover Segue and subsequent display of the popover containing the PopViewController UIView.</p> <p><strong>NewGameViewController.h</strong></p> <pre><code>#import "PopViewController.h" @interface NewGameViewController: UIViewController &lt;DismissPopoverDelegate&gt; { UIPopoverController *popover; } </code></pre> <p><strong>NewGameViewController.m</strong></p> <pre><code>@implementation NewGameViewController -(void)prepareForSegue:(UIStoryboardPopoverSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"popoverSegue"]) { popover = [(UIStoryboardPopoverSegue *)segue popoverController]; // getting warning: Assigning to 'id&lt;UIPopoverControllerDelegate&gt;' from incompatible type 'NewGameViewController *const__strong' //popover.delegate = self; } } -(void)dismissPopover { [popover dismissPopoverAnimated:YES]; } </code></pre> <p><strong>PopViewController.h</strong></p> <pre><code>@protocol DismissPopoverDelegate &lt;NSObject&gt; -(void) dismissPopover; @end @interface PopViewController: UIViewController { __unsafe_unretained id&lt;DismissPopoverDelegate&gt; delegate; } @property (nonatomic, assign) id&lt;DismissPopoverDelegate&gt; delegate; -(IBAction)dismissPopoverButtonPressed:(id)sender; @end </code></pre> <p><strong>PopViewController.m</strong></p> <pre><code>#import "NewGameViewController.h" @implementation PopViewController @synthesize delegate; -(IBAction)dismissPopoverButtonPressed:(id)sender { [self.delegate dismissPopover]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload