PDA

View Full Version : Storyboard and popover views...




Ubuntu
Aug 29, 2012, 09:44 AM
Hello,

I've been quite happily finishing off my application, which uses storyboards and popover viewcontrollers. This all works fine, except I recently noticed that one can press the initiating button however many times they like and it'll create a new instance of the view controller each time.

Before storyboards I worked a bit with popover views using a popovercontroller which seems to prevent this issue.

Has anyone got any experience of how to fix this issue while still using Storyboards - and ideally not having to resort to the disabling and reenabling of buttons?

Thanks



Scott90
Sep 3, 2012, 07:23 PM
Create a (private) property of type UIPopoverController. In prepareForSegue, do the following:


if ([segue isKindOfClass:[UIStoryboardPopoverSegue class]]) {

if (self.popover.popoverVisible)
[self.popover dismissPopoverAnimated:NO]; // No animation needed; other UIPopover is taking over

self.popover = [(UIStoryboardPopoverSegue *)segue popoverController];
}


This basically dismisses any visible popover before it shows the new one.

Ubuntu
Sep 6, 2012, 07:45 AM
Create a (private) property of type UIPopoverController. In prepareForSegue, do the following:


if ([segue isKindOfClass:[UIStoryboardPopoverSegue class]]) {

if (self.popover.popoverVisible)
[self.popover dismissPopoverAnimated:NO]; // No animation needed; other UIPopover is taking over

self.popover = [(UIStoryboardPopoverSegue *)segue popoverController];
}


This basically dismisses any visible popover before it shows the new one.

That worked beautifully. Thanks.