私は次のコードを動作させようとしています。これは初めてのことですが、ウィンドウを開き、それをフロントウィンドウにしますが、それ以降呼び出されたときには、ウィンドウがゼロであるためorderFront:
は機能しません。なぜinitWithWindowNibName:
initWithNibName:
から返されたNSWindowController
オブジェクトのウィンドウフィールドが設定されていませんか?initWithWindowNibNameを実行しないウィンドウを設定するフィールド
//
// CustomerCard.m
// POSWonder
//
// Created by kaydell on 2/26/12.
// Copyright 2012 Kaydell Leavitt. All rights reserved.
//
#import "CustomerCard.h"
@implementation CustomerCard
// declare customerCard as a static variable
static CustomerCard* customerCard;
+(void) show {
// if the customer card isn't instantiated, then instantiate it
if (customerCard == nil) {
customerCard = [[CustomerCard alloc] initWithWindowNibName:@"CustomerCard"];
if (!customerCard.window) {
NSLog(@"Why is window nil here?"); // <<<<<<<<<<< This line gets called <<<<<
}
}
// show the customer card and make it the front window
[customerCard showWindow:self];
[customerCard.window orderFront:self]; // <<<<<<<< This line doesn't seem to do anything
}
-(void) dealloc {
customerCard = nil;
[super dealloc];
}
@end
私はウィンドウを閉じなかった。他のウィンドウが作成され、フロントウインドウになりました。私はちょうどコードで、顧客のカードを再びフロントウィンドウにすることができるようにしたい。 – Kaydell