问题
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