How to make a call programmatically?

前端 未结 3 1519
爱一瞬间的悲伤
爱一瞬间的悲伤 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 20:54

      NSLog(@"Phone calling...");
    
            UIDevice *device = [UIDevice currentDevice];
    
            NSString *cellNameStr = [NSString stringWithFormat:@"%@",self.tableCellNames[indexPath.row]];
    
            if ([[device model] isEqualToString:@"iPhone"] ) {
    
                NSString *phoneNumber = [@"tel://" stringByAppendingString:cellNameStr];
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
    
            } else {
    
                UIAlertView *warning =[[UIAlertView alloc] initWithTitle:@"Note" message:@"Your device doesn't support this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    
                [warning show];
            }
    

    // VKJ

提交回复
热议问题