Detect moment when newline starts in UITextView

后端 未结 8 862
甜味超标
甜味超标 2020-12-08 16:23

I try to detect when carriage goes at new line in UITextView. I can detect it by comparison total later width with UITextView width:

CGSize size = [textView.         


        
8条回答
  •  暖寄归人
    2020-12-08 17:06

    You can use the UITextViewDelegate

    - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText: (NSString *)text
    {
         BOOL newLine = [text isEqualToString:@"\n"];
         if(newLine)
         {
              NSLog(@"User started a new line");
         }
         return YES;
    }
    

提交回复
热议问题