[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10010"]];//打電話
UIWebView*callWebview =[[UIWebView alloc] init]; NSURL *telURL =[NSURL URLWithString:@"tel:10010"]; [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]]; //記得添加到view上 [self.view addSubview:callWebview];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://10010"]];
2、發簡訊
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"sms://10010"]];//發簡訊
iOS4.0新加入了MFMessageComposeViewCont
body :簡訊內容
添加協議:
#import <MessageUI/MessageUI.h>@interface DemoViewController : UIViewController <MFMessageComposeViewControllerDelegate>@end
- (void)showMessageView{ if( [MFMessageComposeViewController canSendText] ){ MFMessageComposeViewController * controller = [[MFMessageComposeViewController alloc]init]; //autorelease]; controller.recipients = [NSArray arrayWithObject:@"10010"]; controller.body = @"測試發簡訊"; controller.messageComposeDelegate = self; [self presentModalViewController:controller animated:YES]; [[[[controller viewControllers] lastObject] navigationItem] setTitle:@"測試簡訊"];//修改簡訊介面標題 }else{ [self alertWithTitle:@"提示資訊" msg:@"裝置沒有簡訊功能"]; } }//MFMessageComposeViewControllerDelegate- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{ [controller dismissModalViewControllerAnimated:NO];//關鍵的一句 不能為YES switch ( result ) { case MessageComposeResultCancelled: [self alertWithTitle:@"提示資訊" msg:@"發送取消"]; break; case MessageComposeResultFailed:// send failed [self alertWithTitle:@"提示資訊" msg:@"發送成功"]; break; case MessageComposeResultSent: [self alertWithTitle:@"提示資訊" msg:@"發送失敗"]; break; default: break; }}- (void) alertWithTitle:(NSString *)title msg:(NSString *)msg { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:nil otherButtonTitles:@"確定", nil]; [alert show]; }
@張興業TBOW
參考:
http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMessageComposeViewController_class/Reference/Reference.html