更换UITextView的换行键为完成键

来源:互联网 发布:窦靖童唱功知乎 编辑:程序博客网 时间:2024/05/17 21:50

- (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"]) {

        // Be sure to test for equality using the "isEqualToString" message

        [textView resignFirstResponder];

        

        // Return FALSE so that the final '\n' character doesn't get added

        return FALSE;

    }

    // For any other character return TRUE so that the text gets added to the view

    return TRUE;

}

0 0
原创粉丝点击