Reputation: 141
i have UITextView with lines. here i added text in UITextView, while i click the next line button(return/enter) ,The text start printing before the margin .but the text should start after the margin, so i want to leave space before the text, when i entered the next line event.
Here is my code below
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
if ([text isEqualToString:@"\n"])
{
note.text=[note.text stringByAppendingString:@" "];
}
NSLog(@"%@",text);
return YES;
}
Upvotes: 0
Views: 243
Reputation: 3793
Try this:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
if ([text isEqualToString:@"\n"])
{
note.text=[note.text stringByAppendingString:@"\n "];
return NO;
}
NSLog(@"%@",text);
return YES;
}
Upvotes: 2