当用户点击iPhone键盘上的“发送”按钮时,如何执行选择器?
我有一个新的观点。当用户点击Send键时,我希望能够自动执行选择器。我该怎么做?我知道尤特菲尔德有当用户点击iPhone键盘上的“发送”按钮时,如何执行选择器?,iphone,objective-c,cocoa-touch,uitextview,Iphone,Objective C,Cocoa Touch,Uitextview,我有一个新的观点。当用户点击Send键时,我希望能够自动执行选择器。我该怎么做?我知道尤特菲尔德有 -(BOOL)textField应该返回:(UITextField*)textField您可以使用 [self performSelector:@selector(aMethod) withObject:nil afterDelay:0.1]; 在 希望它对您有所帮助。尝试一下: - (BOOL)textView:(UITextView *)textView shouldChangeTextIn
-(BOOL)textField应该返回:(UITextField*)textField
您可以使用
[self performSelector:@selector(aMethod) withObject:nil afterDelay:0.1];
在
希望它对您有所帮助。尝试一下:
- (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"]) {
// If the Done button was pressed, resign the keyboard.
[textView resignFirstResponder];
// Return FALSE so that the final '\n' character doesn't get added.
return NO;
}
// For any other character return TRUE so that the text gets added to the view.
return YES;
}
希望有帮助 我有一个新的观点。您建议的委托方法适用于不同的UITextField。
- (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"]) {
// If the Done button was pressed, resign the keyboard.
[textView resignFirstResponder];
// Return FALSE so that the final '\n' character doesn't get added.
return NO;
}
// For any other character return TRUE so that the text gets added to the view.
return YES;
}