zoukankan      html  css  js  c++  java
  • 【小技巧】【源码】iOS复制电话本号码消除空格的方法

    iOS11,复制电话本联系人电话时,复制的不是11位的手机号而是15位,这是系统bug,iOS如何复制电话本号码消除空格呢,直接上代码

    //结束编辑
    -(void)textViewDidEndEditing:(UITextView *)textView
    {
    // 去掉数字
    NSLog(@"%lu",(unsigned long)textView.text.length);

    NSMutableString *strippedString = [NSMutableString
    stringWithCapacity:textView.text.length];
    NSScanner *scanner = [NSScanner scannerWithString:textView.text];
    NSCharacterSet *numbers = [NSCharacterSet
    characterSetWithCharactersInString:@"0123456789"];
    while ([scanner isAtEnd] == NO) {
    NSString *buffer;
    if ([scanner scanCharactersFromSet:numbers intoString:&buffer]) {
    [strippedString appendString:buffer];
    }
    else {
    [scanner setScanLocation:([scanner scanLocation] + 1)];
    }
    }
    NSLog(@"%@", strippedString);
    textView.text = strippedString;
    NSLog(@"%lu",(unsigned long)textView.text.length);
    }

  • 相关阅读:
    SpringRequestContext源码阅读
    MyBatis事务管理源码阅读
    linux查找依赖文件
    GitHub
    Qt Quick
    centos7下安装chrome
    软件使用
    排序算法之冒泡排序
    c++学习
    cent6.4使用
  • 原文地址:https://www.cnblogs.com/wangbinios/p/8474590.html
Copyright © 2011-2022 走看看