在UITextView中禁用返回键 [英] Disable return key in UITextView
本文介绍了在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;
}
这篇关于在UITextView中禁用返回键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文