Disable return key in UITextView

后端 未结 5 1241
小鲜肉
小鲜肉 2021-02-06 23:55

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 t

5条回答
  •  一个人的身影
    2021-02-07 00:29

    Try to use like this..

    - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
    
        if([text isEqualToString:@"\n"])
        {
            [textView resignFirstResponder];
            return NO;
        }
    
        return YES;
    }
    

提交回复
热议问题