NSPopover ~ resize to match content?
NSPopover ~ resize to match content?
- Subject: NSPopover ~ resize to match content?
- From: Erik Stainsby <email@hidden>
- Date: Mon, 23 Apr 2012 17:18:40 -0700
I'm trying to make a popover view resize to fit the content-of-the-moment. This is probably trivial and I have being over thinking myself into complications.
I have three classes of information to display in turn in a popover. The user clicks a segment control to advance and may return if she wishes. My window xib contains the popover view and three differently sized 'client' views which are swapped in as needed. Great, works like a charm.
However I cannot for the life of me cause the popover 'host' view to resize. When I dump the dimensions to NSLog the outer view frame reports the correct (resized as I specified) dims. but the popover has not been resized. The numbers do not match the picture.
What am I missing? Some code:
- (void) showPanel:(NSView*)panel {
// guard
if(!panel) panel = actionPanel;
[self setActivePanelWidth: panel.frame.size.width];
[self setActivePanelHeight: panel.frame.size.height];
NSLog(@"%s- [d] %@: %0.2f", __PRETTY_FUNCTION__, __LINE__, [panel className], panel.frame.size.height);
NSRect newFrameSize = self.view.frame;
newFrameSize.size.height = popoverHeader.frame.size.height + activePanelHeight;
NSLog(@"%s- [d] %@: %0.2f", __PRETTY_FUNCTION__, __LINE__, [self.view className], self.view.frame.size.height);
[[self view] setFrame:newFrameSize];
if( currentPanel == nil)
{
[[self view] replaceSubview:[self placeholderBox] with: panel];
}
else {
[[self view] replaceSubview:currentPanel with: panel];
}
// a custom category on NSView
[panel setFrameTopLeftPoint: popoverHeader.frame.origin];
currentPanel = panel;
[locator setCurrentPanel: panel];
[popover showRelativeToRect:[locator bounds] ofView:locator preferredEdge:NSMaxXEdge];
}
Any help appreciated. Thanks.
Erik Stainsby
email@hidden
-------------------------------------
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden