Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Ubuntu

macrumors 68020
Original poster
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
 
Create a (private) property of type UIPopoverController. In prepareForSegue, do the following:

Code:
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.
 
Create a (private) property of type UIPopoverController. In prepareForSegue, do the following:

Code:
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.