I am trying to make NSPopover automatically appear under the icon in the status bar when the user installs my application. Like Google Drive:

I use the exact code mentioned by this answer , which works great for manually displaying a popover (for example, when a user clicks). To automatically display a popover, I added the following line at the end of the method applicationDidFinishLaunching: [self.controller menuletClicked:1]which calls down to showRelativeToRect.... Now it works fine (popper appears right below the icon in the status bar), but in other cases popover appears in the lower left corner of the screen. It works more consistently if I wait a few seconds and then execute this line of code (for example, through dispatch_after...). But still sometimes occasionally fails and shows the bottom of the screen.
Does this mean that something is not "ready"? (as suggested in this question ), but I checked that the popover object is not zero, and the borders of the rectangle look good. I also added loadView to try to load the load, but nothing works!
What is the correct way to automatically appear NSPopover? Or how to make sure that it appears in the right place? thank!!
source
share