UITextPosition* beginning = _commentTextView.beginningOfDocument;
    
    UITextRange* selectedRange = _commentTextView.selectedTextRange;
    UITextPosition* selectionStart = selectedRange.start;
    
    //获取光标所在位置
    NSInteger location = [_commentTextView offsetFromPosition:beginning toPosition:selectionStart];
    
    NSRange range = NSMakeRange(location-1, 1);
NSString *newText = [_commentTextView.text stringByReplacingCharactersInRange:range withString:@""];
_commentTextView.text = newText;
//重新设置光标的位置
_commentTextView.selectedRange = NSMakeRange(location-1, 0);

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
  • 2021-09-01
  • 2021-12-20
猜你喜欢
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
  • 2022-01-16
  • 2022-01-17
  • 2022-12-23
相关资源
相似解决方案