1

First of all, I've found a similar question but it does not do the exact same thing I want: UIStoryboardPopoverSegue opening multiple windows on button touch

I have a tool bar with a button that presents a popOver, all wired up with the storyboard.

The problem is that each time I press a button, a new popOver comes up, over the previous one.

In the other question, they suggest this code:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([segue isKindOfClass:[UIStoryboardPopoverSegue class]]){
        // Dismiss current popover, set new popover
        [currentPopover dismissPopoverAnimated:YES];
        currentPopover = [(UIStoryboardPopoverSegue *)segue popoverController];
    }
}

But what it does is, when you press the button, it dismisses the previous popOver (if there's one) and continues with the segue to show a new popOver.

What I want to do is for the button to act as a toggle, meaning that it dismisses the popOver if there's one (not showing a new one) and shows a popOver if there's not one already.

That, by the way, is how it used to work for me without the storyboard.

Community
  • 1
  • 1
Odrakir
  • 4,254
  • 1
  • 20
  • 52

1 Answers1

1

I think this answer answers your question. Basically you change the action of the button each time it's pressed to either display or dismiss the popover.

Community
  • 1
  • 1
Symmetric
  • 4,013
  • 3
  • 27
  • 33