Note that there are some explanatory texts on larger screens.

plurals
  1. POUIPopoverController dismisses without delegate call
    primarykey
    data
    text
    <p>I have a map view which i am adding and removing <code>annotations</code> from based on a switch in a <code>popovercontroller</code>. When i touch outside the <code>popover</code>, it dismisses correctly and calls the <code>delegate</code> method <code>popoverControllerDidDismissPopover:</code> The problem that i am having is that when i toggle the switch in the <code>popover</code> (touching within the popover view), if i am removing the <code>annotations</code> from the map it behaves correctly and the popover stays visible but if i am adding the <code>annotations</code> to the map view, then the <code>popover</code> disappears and the <code>delegate</code> method is not called. Has anyone come across this behavior before?</p> <p>The only difference between the on and off code of the switch is that one removes the <code>annotations</code> from an array, while the other adds the <code>annotations</code>. This is only a problem when adding the <code>annotations</code> to the map view. Any help or suggestions would be appreciated.</p> <p>This is how the <code>popover</code> is displayed:</p> <pre><code>-(IBAction)toggleMapFiltersView:(id)sender { LayerPopoverViewController *popOverViewController = [[LayerPopoverViewController alloc] init]; [popOverViewController setDelegate:self]; [popOverViewController setBranchesShowing:branchesShowing]; [popOverViewController setSchoolsShowing:schoolsShowing]; [layersButton setSelected:YES]; popoverController = [[UIPopoverController alloc] initWithContentViewController:popOverViewController]; [popoverController setDelegate:self]; [popOverViewController release]; [popoverController presentPopoverFromRect:layersButton.frame inView:[self view] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } </code></pre> <p>This is the method that is being called from the popover view:</p> <pre><code>-(IBAction)toggleSchools:(id)sender { if ([self.delegate respondsToSelector:@selector(didChangeSchoolsDisplaySettingWithVisible:)]) { if ([schoolsSwitch isOn]) { [self.delegate didChangeSchoolsDisplaySettingWithVisible:YES]; self.schoolsShowing = YES; } else { [self.delegate didChangeSchoolsDisplaySettingWithVisible:NO]; self.schoolsShowing = NO; } } } </code></pre> <p>and this is the method it is referring to:</p> <pre><code>-(void)didChangeSchoolsDisplaySettingWithVisible:(BOOL)visible { if (visible == YES) { schoolsShowing = YES; if (self.schoolArray != nil &amp;&amp; [self.schoolArray count] &gt; 0) { for (MySchool *school in self.schoolArray) { [mapView addAnnotation:school]; } } } else { schoolsShowing = NO; for (id&lt;MKAnnotation&gt; annotation in mapView.annotations) { if ([annotation isKindOfClass:[MySchool class]]) { [mapView removeAnnotation:annotation]; } } } } </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.
    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