objective-c - 未调用 textDidChange ( NSTextFieldDelegate )

标签 objective-c macos cocoa

第一步.在xib中添加一个NSTextField

第 2 步。在 .h 文件中添加 NSTextFieldDelegate,按住 Control 键拖动 NSTextField 到文件的所有者以将委托(delegate)设置给它

第三步,在.m文件中添加方法:

- (void)textDidChange:(NSNotification *)notification{
    NSLog(@"textDidChange");
}

但是方法 textDidChange: 没有被调用?

有没有错?

最佳答案

文件的所有者不是应用程序委托(delegate) - 应用程序委托(delegate)是您放置该方法的地方吗?您应该控制拖动到标记为应用委托(delegate)的蓝色立方体。

编辑后:委托(delegate)收到的消息是 controlTextDidChange: 而不是 textDidChange,因此请改为实现该消息。

关于objective-c - 未调用 textDidChange ( NSTextFieldDelegate ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11680784/

相关文章:

Swift 中的 C# PathGeometry 等价物

iphone - 使用 iPhone 加速度计沿 x 轴移动 Sprite

macos - -bash : initdb: command not found

iphone - 理论上是: How is the alpha component premultiplied into the other components of an PNG in iPhone OS,,如何才能正确地对其进行预乘呢?

cocoa - 如何隐藏 nssplitview 的分隔线?

cocoa - 如何将自定义项添加到 Cocoa 中 NSTextField 的上下文菜单中?

IOS - UiProgressView - 在 100% 时触发事件

ios - iOS 10 中的 HTTP/2 服务器推送

c++ - 如何在 Xcode 中包含 <bits/stdc++>

python - Mac 上 Python 的 Midi 库