系统方法解读

iOS APP 跳转系统发送短信功能

2017-06-22  本文已影响2052人  WS_0909
  1. 导入 #import <MessageUI/MessageUI.h>

  2. 遵守协议 MFMessageComposeViewControllerDelegate

  3. 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(@"发送失败");
    }
}

上一篇 下一篇

猜你喜欢

热点阅读