У меня есть UITextView. Когда пользователь нажимает кнопку Отправить, я хочу иметь возможность автоматически выполнять селектор. Как я могу это сделать? Я знаю, что UITextField имеет
- (BOOL)textFieldShouldReturn:(UITextField *)textField
Попробуйте это:
- (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; }
Надеюсь, что поможет!
вы можете использовать
[self performSelector:@selector(aMethod) withObject:nil afterDelay:0.1];
в
- (BOOL)textViewShouldEndEditing:(UITextView *)textView { return YES; }
Надеюсь, это поможет вам ..