1. 程式人生 > >iPhone 程式碼實現打電話的另一種方式

iPhone 程式碼實現打電話的另一種方式

NSURL  url= [NSURL URLWithString:@"tel:+12125551212"];

     NSString *osVersion = [[UIDevice currentDevice] systemVersion];

     if ([osVersion floatValue] >= 3.1) {
          UIWebView *webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
          [webview loadRequest:[NSURLRequest requestWithURL:url]];

          // 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];          
     }