UITextView限制输入长度

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{  
    if (range.location > 16 || textView.text.length > 16)
        return FALSE;  
    return TRUE;  
}  

 
 
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string  
{  
    if (range.location > 16 || textField.text.length > 16) 
         return NO;   
    return YES;  
}  

你可能感兴趣的:(UITextView限制输入长度)