Reputation: 914
I have a xib with my view and an NSPopover with Transient behavior:
In the view controller, I have an action to control the popover like this:
@IBAction func moreClicked(sender: NSButton) {
if !moreOpen {
moreOpen = true
scriptsPopover.showRelativeToRect(sender.bounds, ofView: sender, preferredEdge: 2)
} else {
moreOpen = false
scriptsPopover.close()
}
}
When I click my button the popover appears as expected. But after 5 seconds it disappears.
I want the popover to present a number of buttons and only disappear when the user clicks one of those buttons or clicks elsewhere in the UI. Like the Autolayout Pin button in Interface Builder to mention an example.
I tried defining the behavior as Transient, Semi-transient, Application-defined. All have exactly the same result: It dismisses itself after a few seconds.
I tried implementing the popoverShouldClose delegate and returning false to let me control it. It does block the close, but when the user clicks the button to close, it just opens a new popover on top of the old. The popover also loses its arrow after I return false from popoverShouldClose, which looks weird.
Here's a recording of the annoying automatic close
Upvotes: 2
Views: 1102
Reputation: 9387
See the stack trace when the popoverShouldClose
method is called. You'll see the cause of this in that stack trace, and from there, try to eliminate this cause.
What I'm suspecting is that your popover is being deallocated as it isn't being strongly held by you.
Upvotes: 4