iOS小技巧--- 應用中拔打電話

- (void)callPhone:(id)sender {app

    //方法一:用UIWebView實現,打電話會返回當前應用程序,合法可在APPSTORE 發佈spa

    UIWebView * callPhoneWebVw = [[UIWebView alloc ] init];orm

    NSString *   phoneNumber = @"10086";string

    NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",phoneNumber]]];it

    [callPhoneWebVw loadRequest:request];io

    [self.view addSubview:callPhoneWebVw];request

    //[callPhoneWebVw release];    //不能release  否則不能打電話程序

    

    

    //方法二:使用openURL打電話 返回拔打電話界面,不返回應用程序方法

    //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]]; call

    

    //方法三:使用私有方法打電話 返回應用程序 不能上appstore

    //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://10086"]];

    

    

}

相關文章
相關標籤/搜索