Hi Fritz,
The popover controller is a standard NSViewController which is also acting as
the delegate for the popovers.
I guess I ought to have included the header as well before:
#import <Cocoa/Cocoa.h>
@interface RSPanelPopoverController : NSViewController < NSPopoverDelegate >
@property (weak) IBOutlet NSPopover * popover;
@property (weak) IBOutlet NSBox * box;
@property (assign) NSInteger activePanelWidth;
@property (assign) NSInteger activePanelHeight;
- (void) showPanelPopover:(NSView*)locator activePanel:(NSView*)panel;
@end
I have modified the showPanelPopover: method thus:
- (void) showPanelPopover:(NSView*)locator activePanel:(NSView*)panel {
[self setActivePanelWidth: panel.frame.size.width];
[self setActivePanelHeight: panel.frame.size.height];
[panel setFrameOrigin: self.view.bounds.origin]; // new
line
[[self view] replaceSubview:[self box] with:panel];
[[self popover] showRelativeToRect:[locator bounds] ofView:locator
preferredEdge:NSMinYEdge];
}
with the effect that the view is correctly placed within the popover ON SECOND
VIEWING. The initial load is still rendered off-set by half the vertical
dimension.
Erik Stainsby
[email protected]
-------------------------------------
Consistently place constants on the LHS of an expression: you cannot
accidentally assign when you meant to compare.
On 2012-03-17, at 1:10 PM, Fritz Anderson wrote:
> On 17 Mar 2012, at 2:48 PM, Erik Stainsby wrote:
>
>> I've got a popover controller which loads one of several subviews ('panels'
>> below) as it's content. I have properties on the controller which expose the
>> current panel's height and width. The popover resizes correctly but fails
>> to place the panel correctly. If the replaceSubview:with: is called before
>> the resize (as illustrated) the panel appears shifted down by half it's
>> height, leaving half of the panel content inaccessible. If the
>> -replaceSubview:with: call is placed after the resize, the inserted panel is
>> half invisible off the top edge of the popover.
>>
>> Does anyone understand what on earth is happening? And what I can do about
>> it?
>>
>>
>> @implementation RSPanelPopoverController
>>
>> @synthesize popover = _popover;
>> @synthesize box = _box;
>> @synthesize activePanelWidth;
>> @synthesize activePanelHeight;
>>
>> - (void) showPanelPopover:(NSView*)locator activePanel:(NSView*)panel {
>>
>> [[self view] replaceSubview:[self box] with:panel];
>>
>> [self setActivePanelWidth: panel.frame.size.width];
>> [self setActivePanelHeight: panel.frame.size.height];
>>
>> [[self popover] showRelativeToRect:[locator bounds] ofView:locator
>> preferredEdge:NSMinYEdge];
>> }
>
> I'm not clear on a few things. It appears that the "panel" frame is offset
> one way or the other, but I don't see the frame being set, nor the panel
> being translated. You say that the order of setActivePanel…: matters, but you
> don't show that the methods (odd, but not wrong, that you don't use dot
> notation) do anything but change the value of an instance variable. If they
> actually change view geometry, you'll have to show us.
>
> What class does RSPanelPopoverController descend from?
>
> What is .box? (It appears that it can be replaced only once.) Have you logged
> the frames of .box, .view, and panel, before and after the replacement? And
> .view.bounds?
>
> — F
>
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]