sammcewan / WYPopoverController

WYPopoverController is for the presentation of content in popover on iPhone / iPad devices. Very customizable.
Other
253 stars 74 forks source link

Unable to dismiss popover from popover. #6

Closed 128keaton closed 9 years ago

128keaton commented 9 years ago

Hey everyone, I am having an odd issue thats easy to solve, I probably just can't see it. Basically, I am trying to programmatically dismiss the popover from the popover, for which I haven't had success with. Here is the code I am trying (hooked up to a button in the popover): [self.delegate dismissPopoverAnimated:YES]; where delegate is set to: selectionViewController.delegate = (MasterViewController*) self.view.window.rootViewController; MasterViewController is the view controller from which I am instigating the popover. Any suggestions?

ghost commented 9 years ago

@128keaton - Were you able to solve this ??

128keaton commented 9 years ago

@mdaymond I ended up not using the popover.

128keaton commented 9 years ago

Well, same issue. Any more ideas?

128keaton commented 9 years ago

UIWindow mainWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:0]; for (UIView view in mainWindow.subviews) { if (view.class == [WYPopoverOverlayView class]) { [(WYPopoverOverlayView *)view touchesBegan:nil withEvent:nil]; } NSLog(@"Subviews %@", mainWindow.subviews); }

is how I accomplished it

128keaton commented 8 years ago

Even easier! And in Swift: Parent View (with Popover Controller):

override func viewDidLoad(){
NSNotificationCenter.defaultCenter().addObserver(self, selector: "dismissPopover", name:       "dismissPopover", object: nil)
 }

func dismissPopover(){
   self.popoverController?.dismissPopoverAnimated(true)
}

The actual Popover's View Controller:

func save(){

NSNotificationCenter.defaultCenter().postNotificationName("dismissPopover", object: nil)

}