自己写的拨打电话的代码
#pragma mark - telAction
- (void)telAction
{
// 进入拨打电话页面
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"服务时间:工作日 09:00-17:30" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:[NSString stringWithFormat:@"呼叫:%@-%@-%@",[kCustomerService substringToIndex:3],[kCustomerService substringWithRange:NSMakeRange(3, 3)],[kCustomerService substringFromIndex:6]] otherButtonTitles:nil];
actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic;
[actionSheet showInView:self.view];
}
#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex != [actionSheet cancelButtonIndex]) {
NSString *URLString = [NSString stringWithFormat:@"tel://%@", kCustomerService];
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:URLString]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:URLString]];
} else {
[self toast:@"当前设备中没有通话功能"];
}
}
}