resize nswindow nspanel

resize - No se puede cambiar el tamaño de NSPanel después del tamaño inicial



nswindow (0)

Quiero cambiar el tamaño de un NSPanel cuando un usuario descarta un elemento. Inicialmente puedo dimensionarlo perfectamente:

[super awakeFromNib]; _mustNotAutoSize=FALSE; // Make a fully skinned panel NSPanel *panel = (id)[self window]; [panel setAcceptsMouseMovedEvents:YES]; [panel setLevel:NSPopUpMenuWindowLevel]; [panel setOpaque:NO]; [panel setBackgroundColor:[NSColor clearColor]]; [panel setOpaque:YES]; [panel setBackgroundColor:[NSColor blueColor]]; // Resize panel NSRect panelRect = [[self window] frame]; int nR=[self numberOfReminders]; float desiredHeight=nR*(52.0)+BORDER_INSET*2+ARROW_HEIGHT+ 22.0; if(desiredHeight>POPUP_HEIGHT)desiredHeight=POPUP_HEIGHT; if(desiredHeight<50.0)desiredHeight=50.0; panelRect.size.height = desiredHeight; [[self window] setFrame:panelRect display:NO];

Pero cuando reduzco el número de elementos más tarde y llamo a una función de cambio de tamaño, no funciona:

- (void)sizePanelBasedOnReminders { NSWindow *panel = [self window]; NSRect panelRect = [panel frame]; NSLog(@"Panel height is starting at: %f",panelRect.size.height); int nR=[self numberOfReminders]; float desiredHeight=nR*(52.0)+BORDER_INSET*2+ARROW_HEIGHT+ 22.0; if(desiredHeight>POPUP_HEIGHT)desiredHeight=POPUP_HEIGHT; if(desiredHeight<BORDER_INSET*2+ARROW_HEIGHT+ 22.0)desiredHeight=BORDER_INSET*2+ARROW_HEIGHT+ 22.0; panelRect.size.height = desiredHeight; NSLog(@"Panel height is changing to: %f",panelRect.size.height); [panel setFrame:panelRect display:YES]; }

¿Algunas ideas?

2013-04-12 11:27:47.997 LoveBug[44016:303] Deleted row is: 0 2013-04-12 11:27:47.997 LoveBug[44016:303] Panel height is starting at: 400.000000 2013-04-12 11:27:47.998 LoveBug[44016:303] Numberofitems called, return 6 2013-04-12 11:27:47.998 LoveBug[44016:303] Panel height is changing to: 352.000000 2013-04-12 11:27:48.628 LoveBug[44016:303] Sending 0 2013-04-12 11:27:48.629 LoveBug[44016:303] Deleted row is: 0 2013-04-12 11:27:48.629 LoveBug[44016:303] Panel height is starting at: 352.000000 2013-04-12 11:27:48.630 LoveBug[44016:303] Numberofitems called, return 5 2013-04-12 11:27:48.630 LoveBug[44016:303] Panel height is changing to: 300.000000 2013-04-12 11:27:49.156 LoveBug[44016:303] Sending 0 2013-04-12 11:27:49.156 LoveBug[44016:303] Deleted row is: 0 2013-04-12 11:27:49.157 LoveBug[44016:303] Panel height is starting at: 300.000000 2013-04-12 11:27:49.157 LoveBug[44016:303] Numberofitems called, return 4 2013-04-12 11:27:49.158 LoveBug[44016:303] Panel height is changing to: 248.000000