【发布时间】:2016-09-26 10:45:27
【问题描述】:
我在 my.xib 文件中添加了NSWindow 元素,并在其中插入了一些元素,例如 imageView。然后创建名为customNSWindow 的NSWindow 类型的类并将这些类分配给我创建的xib 元素(NSWindow)。现在从另一个 WindowController 我需要显示/隐藏 customNSWindow。这是通过在 WindowController 上放置一个插座来完成的。
viewController.h
@property (strong) IBOutlet NSWindow *ImageEditWindow;//(custom window)
viewController.mm
-(IBAction)ButtonClick:(id)sender {
if(! [_ImageEditWindow isVisible] ){
[_ImageEditWindow makeKeyAndOrderFront:sender];
}
}
但我不知道如何更新ImageEditWindow 中的图像,我找不到在我创建的自定义类中调用方法的方法,使用_ImageEditWindow 插座。
编辑
这是 NSWindow 的自定义类
CustomIKImageEditor.h
@interface CustomIKImageEditor : NSWindow
@property (weak) IBOutlet IKImageView *IKImg;
-(void) updateIKImage: (NSImage*)staticImageToEdit;
@end
CustomIKImageEditor.mm
-(void) updateIKImage: (NSImage*)staticImageToEdit {
NSDictionary* _imageProperties;
CGImageRef source = [self CGImageCreateWithNSImage: staticImageToEdit];
_imageProperties = NULL;
[_IKImg setImage: source imageProperties: NULL];
}
【问题讨论】:
标签: objective-c macos nswindow