sammcewan / WYPopoverController

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

Dismiss in TableViewController #38

Closed ghost closed 8 years ago

ghost commented 9 years ago

Hi there I have the following setup.

BaseViewController - This controller implements the WYPopoverDelegate and sets up the menu.

ViewController - A view that shows the actual popup of a TableView.

Everything works perfectly, but I can't dismiss the Popup when a item is selected from my TableView. Here is the code I have for dismissing:

In BaseViewController:

    func closeMenu(){
        self.popoverControllerShouldDismissPopover(popoverController)
    }

    func popoverControllerDidDismissPopover(popoverController: WYPopoverController!) {
        println("DISMISS")
        self.popoverController!.delegate = nil
        self.popoverController = nil
    }

In ViewController/Tableview

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        println("You selected cell #\(indexPath.row)!")
        super.closeMenu()
    }
nemphys commented 9 years ago

Though I am not familiar with swift, as I get it you are trying to dismiss the popover calling popoverControllerShouldDismissPopover, which is actually a delegate method you view controller (delegate) should implement, not call. In order to dismiss the popover, you should be calling dismissPopoverAnimated: method of the PopoverController (not the presenting, nor the presented view controller).

vitalys commented 8 years ago

@mdaymond call self.popoverController.dismissPopoverAnimated(YES) to dismiss your popover

@nemphys Thank you!