How to make a call programmatically?

前端 未结 3 1502
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 20:16

I need to call programmatically in my app in a button click.

for that i found code like this.

[[UIApplication sharedApplication] openURL:[NSURL URLWi         


        
3条回答
  •  暖寄归人
    2020-11-27 21:04

    Keep the phone number in a separate string.

    NSString *phoneNumber = @"1-800-555-1212"; // dynamically assigned
    NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phoneNumber];
    NSURL *phoneURL = [NSURL URLWithString:phoneURLString];
    [[UIApplication sharedApplication] openURL:phoneURL];
    

提交回复
热议问题