zoukankan      html  css  js  c++  java
  • 删除光标前的字符

     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);
    
  • 相关阅读:
    CodeForces 587A
    矩阵快速幂模板
    LCA模板
    Codeforces Round #226 (Div. 2 )
    Codeforces Round #225 (Div. 2)
    SGU132
    SRM 599 DIV 2
    POJ1038
    SGU223
    POJ1185
  • 原文地址:https://www.cnblogs.com/damiao/p/4481271.html
Copyright © 2011-2022 走看看