美文网首页
UITextView

UITextView

作者: BlessNeo | 来源:发表于2018-03-20 10:41 被阅读7次

    1. UITextView 点击键盘完成或 Done 按钮收起键盘

    Objc

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

    Swift-4.0

    func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
        if text == "\n" {
            textView.resignFirstResponder()
            return false
        }
        return true
    }
    

    How to dismiss keyboard for UITextView with return key?

    相关文章

      网友评论

          本文标题:UITextView

          本文链接:https://www.haomeiwen.com/subject/ziyvqftx.html