美文网首页
打电话,发短信

打电话,发短信

作者: Ever_ccy | 来源:发表于2016-08-17 10:26 被阅读0次

    打电话

    • (void)phoneCall:(NSString *)phoneNumber {
      NSString *cleanedString = [[phoneNumber componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789-+()"] invertedSet]] componentsJoinedByString:@""];
      NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", cleanedString]];
      UIApplication *myApp = [UIApplication sharedApplication];
      [myApp openURL:telURL];
      }

    发短信

    +(void)sms:(NSString *)phoneNumber
    {
    NSString *cleanedString = [[phoneNumber componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789-+()"] invertedSet]] componentsJoinedByString:@""];
    NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"sms:%@", cleanedString]];
    UIApplication *myApp = [UIApplication sharedApplication];
    [myApp openURL:telURL];
    }

    相关文章

      网友评论

          本文标题:打电话,发短信

          本文链接:https://www.haomeiwen.com/subject/hndmsttx.html