繁体   English   中英

单击表格视图单元格时调用

[英]Call when clicked on tableview cell

我正在制作一个UITableView ,您可以在其中单击tableviewcell ,这应该会触发对阵列中电话号码的电话。

电话号码以阵列形式列出,并且这些号码也显示在tableviewcell

_Number = @[@"100",
          @"101",
          @"070 245 245"];

我是新来的,我不知道如何开始,我已经有了我的tableviewcontroller和tableviewcell类。

格拉茨,在此先感谢

您可以执行以下操作:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *phoneNumber = [Number objectAtIndex:indexPath.row];

    NSURL *phoneNumberURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",   phoneNumber]];

    if( [[UIApplication sharedApplication] canOpenURL:phoneNumberURL] )
    {
        [[UIApplication sharedApplication] openURL:phoneNumberURL];
    }
    else
    {
        UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Alert!!!" message:@"Not able to make a phone call." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
                [errorAlert show];
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM