Saturday, 23 February 2013

To set limit for character input in UITextView and also edit by pressing back.


// Its a delegate just add this method for using.

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    if([text length] == 0)
    {
        if([textView.text length] != 0)
        {
            return YES;
        }
        else {
            return NO;
        }
    }
    else if([[textView text] length] > your limit value ) 
    {
        return NO;
    }
    return YES;
    
}