Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当用户点击iPhone键盘上的“发送”按钮时,如何执行选择器?_Iphone_Objective C_Cocoa Touch_Uitextview - Fatal编程技术网

当用户点击iPhone键盘上的“发送”按钮时,如何执行选择器?

当用户点击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

我有一个新的观点。当用户点击Send键时,我希望能够自动执行选择器。我该怎么做?我知道尤特菲尔德有

-(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;
}