一、調用 iOS系統自帶mail瀏覽器
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hzlzh.com"]];
二、調用 打電話phoneiphone
<1>通常在應用中撥打電話的方式是 iphone界面會停留在電話界面 :函數
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://159*****334"]];
<2>用以下方式,能夠使得用戶結束通話後自動返回到應用: spa
UIWebView*callWebview =[[UIWebView alloc] init]; NSURL *telURL =[NSURL URLWithString:@"tel://159*****334"];// 貌似tel:// 或者 tel: 都行 [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]]; [self.view addSubview:callWebview];
<3>還有一種私有方法:(可能不能經過審覈)代理
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://10086"]];
三、調用SMS code
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];
PS:blog
調用phone能夠傳遞號碼,調用SMS 只能設定號碼,不能初始化SMS內容。ip
若須要傳遞內容能夠作以下操做:
加入:MessageUI.frameworkci
#import <MessageUI/MFMessageComposeViewController.h>it
實現代理:MFMessageComposeViewControllerDelegate
調用sendSMS函數
//內容,收件人列表
- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients { MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease]; if([MFMessageComposeViewController canSendText]) { controller.body = bodyOfMessage; controller.recipients = recipients; controller.messageComposeDelegate = self; [self presentModalViewController:controller animated:YES]; } }
// 處理髮送完的響應結果 - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result { [self dismissModalViewControllerAnimated:YES]; if (result == MessageComposeResultCancelled) NSLog(@"Message cancelled") else if (result == MessageComposeResultSent) NSLog(@"Message sent") else NSLog(@"Message failed") }
默認發送短信的界面爲英文的,解決辦法爲:
在.xib 中的Localization添加一組Chinese就ok了
四、四、調用 iOS系統自帶瀏覽器safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.baidu.com"]];