在UITextView中禁用返回键
问题描述:
我正在尝试禁用在 UITextView
中键入时找到的返回键。我希望文本没有像在 UITextField
中找到的页面缩进。这是我到目前为止的代码:
I am trying to disable the return key found when typing in a UITextView
. I want the text to have no page indents like found in a UITextField
. This is the code I have so far:
- (BOOL)textView:(UITextView *)aTextView shouldChangeTextInRange:(NSRange)aRange replacementText:(NSString*)aText
{
if ([aTextView.text isEqualToString:@"\r\n"]) {
return NO;
}
任何想法?
答
尝试使用这样的..
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if([text isEqualToString:@"\n"])
{
[textView resignFirstResponder];
return NO;
}
return YES;
}