轉載自: http://tech.cncms.com/shouji/iphone/96183.htmlhtml
一、調用 自帶mail
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hzlzh.com"]];瀏覽器
二、調用 電話phone
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];
iOS應用內撥打電話結束後返回應用
通常在應用中撥打電話的方式是:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://123456789"]];iphone
使用這種方式撥打電話時,當用戶結束通話後,iphone界面會停留在電話界面。
用以下方式,能夠使得用戶結束通話後自動返回到應用:
UIWebView*callWebview =[[UIWebView alloc] init];
NSURL *telURL =[NSURL URLWithString:@"tel:10086"];// 貌似tel:// 或者 tel: 都行
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
//記得添加到view上
[self.view addSubview:callWebview];ide
還有一種私有方法:(可能不能經過審覈)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://10086"]];函數
三、調用 SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];spa
四、調用自帶 瀏覽器 safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];代理
調用phone能夠傳遞號碼,調用SMS 只能設定號碼,不能初始化SMS內容。orm
若須要傳遞內容能夠作以下操做:
加入:MessageUI.frameworkhtm
#import <MessageUI/MFMessageComposeViewController.h>ip
實現代理: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了