iphone常用控件之电话拨打

拨打电话,

按钮触发toCall事件:

-(void)toCall {
    @try {
        [appDelegate showAlert:self Tag:777 Title:@"" Message:@"拨打400-000-4040电话咨询?" cancelButton:@"确定" otherButton:@"取消",nil];

    }
    @catch (NSException *exception) {
        [appDelegate showAlert:self Tag:111 Title:@"" Message:@"拨打电话失败" cancelButton:@"确定" otherButton:nil];
    }
    @finally {
        
    }
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (alertView.tag==777) {
        if(buttonIndex == 0)
            
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://4000004040"]];     //关键代码

//或则

             // NSString *phone_temp_call=[phone_tempstringByReplacingOccurrencesOfString:@"-"withString:@""];

             // NSLog(@"phone_temp_call  is %@",phone_temp_call);

             // [[UIApplicationsharedApplication] openURL:[NSURLURLWithString:[NSStringstringWithFormat:@"tel://%@",phone_temp_call]]];


    } 
}
posted @ 2012-08-20 09:58  小、  阅读(247)  评论(0编辑  收藏  举报