Re: NSPopover will not morph or resize
Re: NSPopover will not morph or resize
- Subject: Re: NSPopover will not morph or resize
- From: Gordon Apple <email@hidden>
- Date: Tue, 25 Dec 2012 14:14:59 -0600
- Thread-topic: NSPopover will not morph or resize
Thanks, Kyle. That almost worked correctly. Now the subclassed popover
does change to the correct size. However, the view seems to float over the
popover, and when changed, is offset about 20 pixels to the lower left of
the popover balloon. (I only update the content view¹s frameSize and don¹t
touch the frameOrigin.) Time to update my bug report.
My contention is that the reference implies that NSPopover should handle
this automatically. However, on rereading, it appears that the statement is
ambiguous. They may have meant that calling ³changeSize² animates it. I
had interpreted it to mean that any change in the content size would cause
it to animate. Note that they said ³content size², NOT ³contentSize². I
guess the devil is in the details.
³Changes to the content size of the popover will cause the popover to
animate while it is shown if the animates property is YES.²
I haven¹t found any solution to the popover -> window morph problem. Guess
I will live with it for now.
Here is my subclass code:
- (void)dealloc {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self];
}
- (void) updateFrame:(NSNotification*)notification {
self.contentSize = self.contentViewController.view.frame.size;
}
- (void) addFrameNotification {
NSViewController *vc = self.contentViewController;
NSView *view = vc.view;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(updateFrame:)
name:NSViewFrameDidChangeNotification object:view];
}
- (void) setContentViewController:(NSViewController *)contentViewController
{
[super setContentViewController:contentViewController];
[self addFrameNotification];
}
On 12/24/12 1:30 AM, "Kyle Sluder" <email@hidden> wrote:
> On Sun, Dec 23, 2012, at 03:06 PM, Gordon Apple wrote:
>> > Another issue is that the popover will not resize when its content view
>> > size
>> > changes. It does come up initially in the right size. I even tried
>> > subclassing NSPopover, put an observer on the content view frame, then
>> > set
>> > contentSize.
>
> -[NSView frame] is not KVO-compliant. The correct way to observe a
> view's frame is to register for NSViewFrameDidChangeNotification.
>
> --Kyle Sluder
_______________________________________________
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