[分享]iOS开发-实现在app中拨打电话

实现代码如下:

//拨打电话
-(void)call{    
    UIAlertView * alertView = [[UIAlertView alloc] init];    
    alertView.title = @"确定拨打客服电话?";    
    alertView.message = @"4000-198-716";    
    alertView.delegate = self;    
    [alertView addButtonWithTitle:@"确定"];    
    [alertView addButtonWithTitle:@"取消"];    
    [alertView show];
}
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{    
    if (buttonIndex == 0) {        
        NSURL * url = [NSURL URLWithString:@"tel:4000198716"];        
        if ([[UIApplication sharedApplication] canOpenURL:url]) {                    
            [[UIApplication sharedApplication] openURL:url];        
        } else{            
            [MyUtil showTipText:@"您的设备不支持拨打电话"];        
        }    
    }
}
    原文作者:ShevaKuilin
    原文地址: https://segmentfault.com/a/1190000004537946
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞