How to call (dialing) with “ * ” char in IOS?

亡梦爱人 提交于 2019-12-22 11:07:34

问题


I hope to call with * character. ex> *711313.

Currently, I'm using this code:

NSString *str = [NSString stringWithFormat:@"tel:%@", tmp];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];

I tested two cases:

  1. tmp = @"719929292"; //this is ok. make call.

  2. tmp = @"*7128282"; //app no reaction. not to call.

How can I call with *(star character)?


回答1:


The star may have to be encoded for use in a URL. Try %2A instead of *.

This replacement is not done by stringByAddingPercentEscapesUsingEncoding: since * is a valid URL character, albeit with a special meaning.



来源:https://stackoverflow.com/questions/12909631/how-to-call-dialing-with-char-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!