开发者

Dialing a number

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜