3
votes

I am trying to make a table cell that when tapped calls a phone number and I think the code I must use is;

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

But what happens is that the call gets placed automatically, as soon as the app is opened and therefore I think the problem is the location of the code.
Where does it need to be placed in order to achieve the desired cell functionality?

3

3 Answers

1
votes

In

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
1
votes

It should be placed in the -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath method in the tableview's delegate.

-2
votes

Thank You all for Your kind answers that are correct but (with Your help) I have found a simpler solution;

- (void)didTap_tableViewCell2:(UIView *)cell {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:thenumber"]]; }