NSWindowController
하위 클래스를 사용해야합니다. NSWindowController
은 달성하고자하는 것을 정확하게 수행하도록 특별히 설계되었으며, NSBundle
의 방법을 사용하여 펜촉을 직접로드하면 실행할 몇 가지 문제를 해결합니다. 일반적으로 항상 창을 관리하려면 NSWindowController
하위 클래스를 사용해야합니다.
것은
NSWindowController
의 서브 클래스를 생성합니다
인터페이스 빌더에서
@interface MyWindowController : NSWindowController {}
@end
@implementation MyWindowController
- (id)init
{
self = [super initWithWindowNibName:@"MyWindow"];
if(self)
{
//initialize stuff
}
return self;
}
//this is a simple override of -showWindow: to ensure the window is always centered
-(IBAction)showWindow:(id)sender
{
[super showWindow:sender];
[[self window] center];
}
@end
는 MyWindowController
을하고 당신의 펜촉의 창 개체에 파일의 소유자의 window
콘센트를 연결하는 파일의 소유자의 클래스를 설정합니다.
그런 다음 이렇게하여 창을 표시 할 수 있습니다
아래에있는 내 코드에서
MyWindowController* controller = [[MyWindowController alloc] init];
[controller showWindow:self];
"File Owner의 창 콘센트에 연결"을 제외하고 나는 당신이 이미 말한 모든 것을하고있었습니다. 일단 내가 그 모든 일을했다. 무리 감사! +1하고 똑딱. –
IB의 'Restorable'속성의 선택을 취소하십시오. –
@KeithSmiley 어떤 편집기가'Restorable' 속성입니까, 아니면 더 이상 Xcode 5.x에 적용되지 않습니까? –