Frage

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;
}
War es hilfreich?

Lösung

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;
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top