//拨打电话功能
@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]];
}
}