NSDocumentsにドラッグアンドドロップできるリソースを含むセカンダリウィンドウを追加したいとします。文書ベースのアプリケーションにセカンダリウィンドウを追加する方法
私のプロジェクトが含まれています
1)ResourceWindow.xib
2)ViewController.xib
3)Main.storyboard
@interface AppDelegate()
@property (nonatomic,strong)NSWindowController* wc;
@property (nonatomic, weak)NSWindow* resourceWindow;
@property (nonatomic, strong)ViewController* vc;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
self.wc = [[NSWindowController alloc]initWithWindowNibName:@"ResourceController.xib"];
self.resourceWindow = [self.wc window];
[self.wc showWindow:self];
self.vc = [[ViewController alloc]initWithNibName:nil bundle:nil];
[self.vc.view setFrame:[self.resourceWindow.contentView bounds]];
[self.resourceWindow.contentView addSubview:self.vc.view];
}
self.wc.windowはすぐにゼロでありますそれを割り当てて初期化した後
私にこれをまっすぐに設定してください。
おかげ
EDIT:
ResourceWindow.xibがちょうど窓ウィンドウコントローラが含まれていません。それは問題ですか?カスタムオブジェクトをxibファイルにドラッグアンドドロップし、そのクラスをNSWindowControllerに変更する方法はありますか?
ResourceWindow.xibのファイル所有者は、ウィンドウに接続してウィンドウに接続する必要があります。と "ResourceWindow.xib"≠ "ResourceController.xib"です。 – Willeke