【发布时间】:2020-04-28 08:53:16
【问题描述】:
我有一个设置为可编辑的 NSImageView。当用户删除图像时,我希望能够恢复为默认图像。我尝试更改 NSImageView 在 setter 中绑定的值,但之后不会调用 getter,因此 NSImageView 是空白的,尽管绑定值被设置为另一个图像。这是设置器代码:
-(void)setCurrentDeviceIcon:(NSImage *)newIcon {
[self willChangeValueForKey:@"currentDeviceIcon"];
if(newIcon == nil)
newIcon = [currentDevice defaultHeadsetIcon];
currentDeviceIcon = newIcon;
[self setDeviceChangesMade:YES];
[self didChangeValueForKey:@"currentDeviceIcon"];
}
我应该如何让 NSImageView 更新它的值?
【问题讨论】:
标签: cocoa nsimageview