导入 #import <MessageUI/MessageUI.h>
遵守协议 MFMessageComposeViewControllerDelegate
Btn action
MFMessageComposeViewController *vc = [[MFMessageComposeViewController alloc] init];
// 设置短信内容
vc.body = @"我想法这样的话 http://www.jianshu.com/p/0bac60cb6f38";
// 设置收件人列表
vc.recipients = @[@"15156884539"]; // 号码数组
// 设置代理
vc.messageComposeDelegate = self;
// 显示控制器
[self presentViewController:vc animated:YES completion:nil];
- (void)messageComposeViewController:(MFMessageComposeViewController*)controller didFinishWithResult:(MessageComposeResult)result
{
// 关闭短信界面
[controller dismissViewControllerAnimated:YES completion:nil];
if(result == MessageComposeResultCancelled) {
NSLog(@"取消发送");
} else if(result == MessageComposeResultSent) {
NSLog(@"已经发出");
} else {
NSLog(@"发送失败");
}
}