Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSInteger startChars = 0;
- - (BOOL)textView:aView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
- {
- NSInteger numLines;
- numLines = tView.contentSize.height/tView.font.leading;
- if (numLines == 9)
- {
- if (startChars == 0)
- {
- startChars = tView.text.length;
- }
- NSLog(@"StartChars: %d", startChars);
- NSString *lastLine = [[NSString alloc]initWithString:[[tView text] substringFromIndex:startChars]];
- CGSize lineSize = [lastLine sizeWithFont:tView.font forWidth:tView.contentSize.width lineBreakMode:UILineBreakModeWordWrap];
- [lastLine release];
- if (range.length > text.length)
- {
- return YES;
- }
- else if (numLines == 9 && lineSize.width >= tView.contentSize.width - 45)
- {
- return NO;
- }
- }
- else
- {
- startChars = 0;
- }
- return YES;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement