标签:
导入 MessageUI.framework
#import <MessageUI/MessageUI.h>
实现代理 MFMessageComposeViewControllerDelegate
1 - (void)sendMessage 2 { 3 //发短信 不能设置短信内容 4 //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://10086"]]; 6 //判断能否接收短信 7 if (![MFMessageComposeViewController canSendText]) { 8 return ; 9 } 10 11 //如果要设置内容,我使用MessageUI 12 //1.创建MFMessageComposeViewController 13 MFMessageComposeViewController *msgVc = [[MFMessageComposeViewController alloc] init]; 14 15 //设置电话 16 msgVc.recipients = @[@"10086",@"10010"]; 17 18 //设置内容 19 msgVc.body = detailItem.item.content; 20 21 //设置代理 22 msgVc.messageComposeDelegate = self; 23 24 //显示信息界面 25 [self presentViewController:msgVc animated:YES completion:nil]; 26 } 27 28 #pragma mark 信息的代理方法 29 - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{ 30 // MessageComposeResultCancelled, 31 // MessageComposeResultSent, 32 // MessageComposeResultFailed 33 if (result == MessageComposeResultCancelled || result == MessageComposeResultSent) { 34 [self dismissViewControllerAnimated:YES completion:nil]; 35 } 36 37 }
标签:
原文地址:http://www.cnblogs.com/kinghx/p/5236386.html