您的位置:首页 > 移动开发 > IOS开发

iOS跳转到打电话

2015-08-12 17:25 489 查看
//拨打电话功能

@implementation BKlCallUtil

static
NSString * number;

//创建一个单例
static
BKlCallUtil* callUtil;

+(BKlCallUtil*)getInstance{
if(callUtil ==
nil){

callUtil = [[BKlCallUtil
alloc]
init];
}

return
callUtil;
}

- (void)callPhoneNumber:(NSString *)phoneNumber{

UIAlertView *alert = [[UIAlertView
alloc]
initWithTitle:@"拨打电话"
message:[NSString
stringWithFormat:@"您确认要拨打%@电话吗?",phoneNumber]
 
delegate:self

  cancelButtonTitle:@"确认"

  otherButtonTitles:@"取消",nil];
number = phoneNumber;
[alert
show];
[alert
release];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex ==
0) {

number = [number
stringByReplacingOccurrencesOfString:@"-"
withString:@""];

number = [number
stringByReplacingOccurrencesOfString:@" "
withString:@""];

number = [number
stringByReplacingOccurrencesOfString:@"(86)"
withString:@""];

//NSLog(@"call:%@",number);
NSString* phoneNumberURL = [NSString
stringWithFormat:
@"tel://%@",number];

[[UIApplication
sharedApplication] openURL:[NSURL
URLWithString:phoneNumberURL]];
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios nsstring