I'd like to show a popover with it's arrow to a button that is part of my view (e.g. button is on my main view). I do this in Interface Builder storyboard editor (ctrl drag from button to popup contents view). Popup shows but not attached to the button. What I found for the buttons on the toolbar popover shows attached to the button as expected. Anchor property of the segue is set to this button. Xcode Version 7.0.1 (7A1001).
Edit: images of what I do:
1) Storyboard. First I ctrl drag from toolbar button to first controller, then ctrl drag to second controller from second button.
2) Correctly attached popover
3) Popover not attaches to in-view button.
You are right. Following method shows that the sending view is nil and by default contentview of window is used for popover.
So to fix just check if the positioningView is nil. if yes, set it to be button (create outlet for it).
Add following method to your viewController
- (void)presentViewController:(NSViewController *)viewController asPopoverRelativeToRect:(NSRect)positioningRect ofView:(NSView *)positioningView preferredEdge:(NSRectEdge)preferredEdge behavior:(NSPopoverBehavior)behavior
{
//do custom implementation (workaround)
[super presentViewController:viewController asPopoverRelativeToRect:positioningRect ofView:positioningView preferredEdge:preferredEdge behavior:behavior];
}