开发者

Dialing a number

开发者 https://www.devze.com 2023-01-13 03:48 出处:网络
I read some reference about how to make a call prog开发者_运维技巧rammatically on the iPhone, so I put this in my code :

I read some reference about how to make a call prog开发者_运维技巧rammatically on the iPhone, so I put this in my code :

UIApplication *app = [UIApplication sharedApplication];
NSString *urlString = [NSString stringWithFormat:@"tel:0225225657"];
NSURL *url = [NSURL URLWithString:urlString];
[app openURL:url];

is that correct? If yes, how can I know that my app has dialed that number while i run this in the simulator?


Your code is working. You just can't use it in the simulator. My reasoning is this:

UIApplication *app = [UIApplication sharedApplication];
NSString *urlString = [NSString stringWithFormat:@"http://www.google.com"];
NSURL *url = [NSURL URLWithString:urlString];
[app openURL:url];

This is your code with but with http://www.google.com instead of your telphone URL. It opens Safari and goes to Google. Just test it on your device and it should work.


Shouldn't that be:

NSString *urlString = [NSString stringWithFormat:@"tel://0225225657"];

??

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号