i want only 3 lines in UITextView. And each line will have maximum 29 characters
What i did is
static const NSUInteger MAX_NUMBER_OF_LINES_ALLOWED = 3;
NSMutableString *t = [NSMutableString stringWithString: self.addressTextView.text];
[t replaceCharactersInRange: range withString: text];
NSUInteger numberOfLines = 0;
for (NSUInteger i = 0; i < t.length; i++) {
if ([[NSCharacterSet newlineCharacterSet] characterIsMember: [t characterAtIndex: i]]) {
numberOfLines++;
}
}
return (numberOfLines < MAX_NUMBER_OF_LINES_ALLOWED);
In below delegate method
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
Please let me know that how i can restrict length of each line to max 29 characters.
That is if user type 29 characters in first line then take him to newline.
Thanks in Advance.