iOS app开发:如何解决拨打电话的特殊字符(如*和#)?用于呼叫转移

新手上路,请多包涵

普通的拨打电话如下:
NSString *strForCallHZ = @"tel:10086";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:strForCallHZ]];

但是我要设置“取消呼叫转移”,需要拨打“##21#”。

第一次尝试:直接类比于普通电话。
NSString *strForCallHZ = @"tel:##21#";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:strForCallHZ]];
结果:报错:
LaunchServices: ERROR: There is no registered handler for URL scheme (null)

第二次尝试:加一个编码过程。
NSString *strForCallHZ = @"tel:##21#";
strForCallHZ = [strForCallHZ stringByAddingPercentEscapesUsingEncoding:

              NSUTF8StringEncoding];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:strForCallHZ]];
结果:报错:
LaunchServices: ERROR: There is no registered handler for URL scheme (null)

请问:应该如何解决这种特殊字符的电话拨打问题呢?

阅读 10.6k
2 个回答
NSURL *url = [NSURL URLWithString:@"tel:%23%2321%23"];

试试?

新手上路,请多包涵

我现在也在解决这个问题,楼主你解决了嘛

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题