How to make a call in iphone? [duplicate]

限于喜欢 提交于 2019-12-06 14:23:21

问题


Possible Duplicate:
how to make phone call by using objective c?

I am trying to make a call when I click on the tableview row.

But it is not working.

Here is the code snippiest.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([indexPath row] == 0) {
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"1800-000-000"]];
}
} 

I don't know why it is not working.

Can anyone help me with this?


回答1:


try this link I think it will help you https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html

this ll work try this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:12125551212"]];



回答2:


add tel: protocol

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([indexPath row] == 0) {
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:1800-000-000"]];
}
} 



回答3:


Try this one

    NSString *aPhoneNo = [@"tel://" stringByAppendingString:[itsPhoneNoArray objectAtIndex:[sender tag]]] ;
    NSURL *url= [NSURL URLWithString:aPhoneNo];
    [[UIApplication sharedApplication] openURL:url];

I think it will help you




回答4:


+ (void)openPhone:(NSString *)number {
    NSString *url = [NSString stringWithFormat:@"tel://%@", number];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
} 

Use this and like it.



来源:https://stackoverflow.com/questions/9798822/how-to-make-a-call-in-iphone

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