我在IB中的NSPanel未选中“关闭时释放”。
“在启动时可见”也未选中。
我用下面的命令(由dragToButton激活)淡入NSPanel,它工作得很好
- (IBAction)dragToFile:(id)sender
{
DragImageView *accessory = [[[DragImageView alloc] initWithFrame:NSMakeRect(0,0,71,63)] autorelease];
[accessory setMainContentFolder:self.mainInstallFolder];
[self.dragToFile setFloatingPanel:YES];
[self.dragToFile makeKeyWindow];
[dragImage setMainContentFolder:self.mainInstallFolder];
NSRect frame = dragToFile.frame;
NSRect mainFrame = self.window.frame;
frame.origin.x = mainFrame.origin.x + 550;
frame.origin.y = mainFrame.origin.y + 360;
[dragToFile setFrame:frame display:NO];
//set fade anim params
NSDictionary *fadeInDict = [NSDictionary dictionaryWithObjectsAndKeys:
dragToFile, NSViewAnimationTargetKey,
NSViewAnimationFadeInEffect, NSViewAnimationEffectKey,
nil];
//create fade instance
NSViewAnimation *fadeIn = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects: fadeInDict, nil]];
[fadeIn startAnimation];
[fadeIn release];但是,如果我关闭窗口工具栏上的窗口,它会从windowWillClose通知中触发以下消息
- (void) dragToFileWindowDidClose:(id)sender
{
[dragToFile setAlphaValue:0.0]; //make nspanel 0 alpha so it can fade in again
[dragtoButton setState:NSOffState];
}窗口将关闭,但会完全消失,并且不会在下一次单击dragToButton时返回。
NSPanel具有以下属性
@property (retain) IBOutlet NSPanel *dragToFile;
所以我很确定这个窗口正在被释放,但是我不知道为什么,因为我取消了这个选项。
发布于 2012-11-03 13:41:41
首先,尝试手动使用[dragToFile setReleasedWhenClosed:NO];。
发布于 2012-11-04 04:16:29
谢谢你的建议。我解决了。
代替[self.dragToFile makeKeyWindow];
[self.dragToFile makeKeyAndOrderFront:dragToFile];
不知道为什么这个可以工作,而另一个不能,但它现在可以完美地工作了。
谢谢。
https://stackoverflow.com/questions/13205558
复制相似问题