ios 短信分享没有标题和取消按钮问题
来源:互联网 发布:nginx mysql 安装 编辑:程序博客网 时间:2024/06/05 07:40
#import <MessageUI/MessageUI.h>
3. 遵循协议
<MFMessageComposeViewControllerDelegate,UINavigationControllerDelegate>
4 实现代码
-(void)sendMessage
{
//用于判断是否有发送短信的功能(模拟器上就没有短信功能)
Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
//有短信功能
if ([messageClasscanSendText]) {//发送短信
//实例化MFMessageComposeViewController,并设置委托
messageController = [[MFMessageComposeViewControlleralloc] init];
messageController.messageComposeDelegate =self;
messageController.delegate =self;
UINavigationItem *navigationItem = [[[messageControllerviewControllers] lastObject]navigationItem];
[navigationItem setTitle:@"新信息"];
UIButton* ButSign = [[UIButtonalloc] initWithFrame:CGRectMake(0,0, 40,20)];
[ButSign setTitle:@"取消"forState:UIControlStateNormal];
ButSign.titleLabel.font = [UIFontsystemFontOfSize:15.0];
[ButSign addTarget:selfaction:@selector(msgBackFun)forControlEvents:UIControlEventTouchUpInside];
navigationItem.rightBarButtonItem = [[UIBarButtonItemalloc] initWithCustomView:ButSign];
//拼接并设置短信内容
messageController.body = @“短信内容”;
//设置发送给谁
messageController.recipients = @[@“10086”];
//推到发送试图控制器
[selfpresentViewController:messageControlleranimated:YEScompletion:^{
}];
}
else
{
UIAlertView *alterView = [[UIAlertViewalloc] initWithTitle:@"提示"message:@"该设备没有发送短信的功能~"delegate:nilcancelButtonTitle:@"取消"otherButtonTitles:nil];
[alterView show];
}
}
//发送短信后回调的方法
-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
NSString *tipContent;
switch (result) {
caseMessageComposeResultCancelled:
tipContent = @"发送短信已取消";
break;
caseMessageComposeResultFailed:
tipContent = @"发送短信失败";
break;
caseMessageComposeResultSent:
tipContent = @"发送成功";
break;
default:
break;
}
[controller dismissViewControllerAnimated:YEScompletion:nil];
}
-(void)msgBackFun
{
[messageControllerdismissViewControllerAnimated:YEScompletion:nil];
}
跑下发现OK了。
- ios 短信分享没有标题和取消按钮问题
- iOS开发短信分享时标题和取消按钮消失
- iOS应用程序短信分享和邮件分享
- UISearchDisplayController 自定义取消按钮标题
- ios ShareSDK进行短信分享(没有UI版)
- iOS:电话分享、短信分享和邮件分享
- iOS开发 UISearchController的cancel按钮自定义中文取消,改变按钮标题颜色,去掉边框线
- IOS自定义导航按钮和标题
- iOS 自定义导航栏标题和按钮
- IOS 改变按钮标题位置和缩进
- IOS 自定义导航栏标题和返回按钮标题
- iOS自定义导航栏标题和返回按钮标题
- IOS 自定义导航栏标题和返回按钮标题
- 取消标题和状态栏
- Android:解决DatePickerDialog只有完成按钮、没有取消按钮的问题
- Android:解决DatePickerDialog只有完成按钮、没有取消按钮的问题
- Android:解决DatePickerDialog只有完成按钮、没有取消按钮的问题
- ios短信分享功能
- CentOS下命令行和桌面模式的切换方法
- clang: error: unable to execute command: Segmentation fault: 11
- IOS 隐藏输入法
- Android启动过程深入解析
- Trade.vcxproj 文件
- ios 短信分享没有标题和取消按钮问题
- 刷新tableview上指定的section或cell
- Apache Spark 1.6发布(新特性介绍)
- SSM整合
- STL之智能指针
- std::pair
- Android service
- GPUImage使用
- MAC 查看本机保存的各个密码