博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS 在当前控制器中发送短信
阅读量:7031 次
发布时间:2019-06-28

本文共 1828 字,大约阅读时间需要 6 分钟。

- (void)showMessageViewWithTel:(NSString *)tel{        if( [MFMessageComposeViewController canSendText] ){                MFMessageComposeViewController * controller = [[MFMessageComposeViewController alloc]init]; //autorelease];                controller.recipients = [NSArray arrayWithObject:tel];        controller.body = @"";        controller.messageComposeDelegate = self;                [self presentViewController:controller animated:YES completion:nil];                        [[[[controller viewControllers] lastObject] navigationItem] setTitle:@"测试短信"];//修改短信界面标题    }else{                [self alertWithTitle:@"提示信息" msg:@"设备没有短信功能"];    }}//MFMessageComposeViewControllerDelegate- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{        [controller dismissViewControllerAnimated:NO completion:nil];//关键的一句   不能为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];    }

 

转载于:https://www.cnblogs.com/pretty-guy/p/4549087.html

你可能感兴趣的文章
原生JS 实现复杂对象深拷贝(对象值包含函数)
查看>>
【跃迁之路】【732天】程序员高效学习方法论探索系列(实验阶段489-2019.2.22)...
查看>>
PAT A1060 科学记数法经典例题(全string库解决)
查看>>
仿知乎分享界面
查看>>
最小外接矩形思路以及实现
查看>>
Python是什么?简单了解pythonp-入门
查看>>
利用ES6进行Promise封装总结
查看>>
ES10 特性的完整指南
查看>>
学习threejs走过的坑
查看>>
ThinkSNS+的 SPA(H5)安装教程
查看>>
C++回声服务器_5-多进程版本
查看>>
CSS外边距折叠引发的问题
查看>>
【LeetCode】贪心算法--划分字母区间(763)
查看>>
Android 抖音爆红的口红挑战爬坑总结
查看>>
怎么就没发现华为Mate20 pro有这么多神奇功能!这波黑科技盘它!
查看>>
vue-cli3.0 vue.config.js 配置详解
查看>>
EOSIO 指南(启动你的节点并设置)
查看>>
一文带你看懂cookie,面试前端不用愁
查看>>
Electron + Antd + Mobx 环境搭建
查看>>
我从来不理解JavaScript闭包,直到有人这样向我解释它...
查看>>