qwe*_*rtz 5 delegates text-editor class objective-c nstextview
我有一个类(“ 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
Run Code Online (Sandbox Code Playgroud)
这是我的.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
Run Code Online (Sandbox Code Playgroud)
但是,当我在NSTextView中更改文本时,不要调用controlTextDidChange :!为什么?
感谢您的回答!=)
| 归档时间: |
|
| 查看次数: |
1650 次 |
| 最近记录: |