Thursday 24 May 2012

Call example code in iphone sdk

-(IBAction)btnCallClicked:(id)sender{
   
    NSLog(@"%@",[[CategoryArray objectAtIndex:0]valueForKey:@"r_phone"] );
    NSString *strPhoneNumber = [NSString stringWithFormat:@"tel://%@",[[CategoryArray objectAtIndex:0]valueForKey:@"r_phone"] ];
    //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:
    //strPhoneNumber]];
    NSURL *url= [NSURL URLWithString:strPhoneNumber];
    NSString *osVersion = [[UIDevice currentDevice] systemVersion];
   
    if ([osVersion floatValue] >= 3.1) {
        UIWebView *webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
        [webview loadRequest:[NSURLRequest requestWithURL:url]];
        webview.hidden = YES;
        // Assume we are in a view controller and have access to self.view
        [self.view addSubview:webview];
        [webview release];
        } else {
            // On 3.0 and below, dial as usual
            [[UIApplication sharedApplication] openURL: url];
            }
}

No comments:

Post a Comment