好的,'返回'是'insertNewline',我喜欢这个,但是在上帝的绿色地球中是insertSpace?
所以我试图在用户完成单词后(也就是当他们点击空格键或返回时)调用拼写检查(对于关键字)。但是爸爸需要检测空格键。下面是我正在实现的textView委托方法......
/* listen to commands */
-(BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector
{
BOOL result = NO;
if (@selector(insertNewline:) == aSelector) {
// does something
result = YES;
return result;
}
return result;
答案 0 :(得分:0)
使用 UITextView 的委托方法,如下所示...
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range
replacementText:(NSString *)text
{
// Any new character added is passed in as the "text" parameter
if ([text isEqualToString:@"\n"]) {
//code when return key pressed.
}
else if([text isEqualToString:@" "])
{
//code when space key pressed.
}
// For any other character return TRUE so that the text gets added to the view
return TRUE;
}