一、調用 自帶mail瀏覽器
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@hzlzh.com"]];函數
二、調用 電話phonespa
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];代理
三、調用 SMSip
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];ci
四、調用自帶 瀏覽器 safariit
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];io
調用phone能夠傳遞號碼,調用SMS 只能設定號碼,不能初始化SMS內容。safari
若須要傳遞內容能夠作以下操做:class
加入:MessageUI.framework
#import <MessageUI/MFMessageComposeViewController.h>
實現代理: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")
}
發送郵件的爲:
導入#import <MessageUI/MFMailComposeViewController.h>
實現代理:MFMailComposeViewControllerDelegate
//發送郵件
-(void)sendMail:(NSString *)subject content:(NSString *)content{
MFMailComposeViewController *controller = [[[MFMailComposeViewController alloc] init] autorelease];
if([MFMailComposeViewController canSendMail])
{
[controller setSubject:subject];
[controller setMessageBody:content isHTML:NO];
controller.mailComposeDelegate = self;
[self presentModalViewController:controller animated:YES];
}
}
//郵件完成處理
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
[self dismissModalViewControllerAnimated:YES];
if (result == MessageComposeResultCancelled)
NSLog(@"Message cancelled");
else if (result == MessageComposeResultSent)
NSLog(@"Message sent");
else
NSLog(@"Message failed");
}
默認發送短信的界面爲英文的,解決辦法爲:
在.xib 中的Localization添加一組chinese就ok了