我有一个类("TextEditorViewController"),里面有一个NSTextView ("textView")对象。我已经在我的.xib文件中将它与NSTextView连接起来。下面是我的.h文件:
#import <Foundation/Foundation.h>
@interface TextEditorViewController : NSObject {
IBOutlet NSTextView *textView; // connected in MainMenu.xib
IBOutlet NSTextField *displayCharacters; // connected in MainMenu.xib
}
@end下面是我的.m文件:
#import "TextEditorViewController.h"
@implementation TextEditorViewController
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSLog(@"applicationDidFinishLaunching called"); // printed to the debugger
[textView setDelegate:(id)self];
}
- (void)controlTextDidChange:(NSNotification *)obj {
NSLog(@"controlTextDidChange called"); // don't printed to the debugger ???
[displayCharacters setIntValue:[[textView string] length]];
}
@end但是当我更改NSTextView中的文本时,它不会调用controlTextDidChange:!为什么?
谢谢你的回答!=)
发布于 2012-07-11 20:42:28
在新项目中重新构建文件后,它可以正常工作。看起来像是文件管理配置问题。
发布于 2012-03-05 20:34:13
将委派零件移动到viewDidLoad。
你为什么不把这个放到一个视图控制器上呢?
https://stackoverflow.com/questions/9566659
复制相似问题