代码:

ViewController.h

#import <UIKit/UIKit.h>
//短信分享
#import <MessageUI/MFMailComposeViewController.h>
#import <MessageUI/MFMessageComposeViewController.h> @interface ViewController : UIViewController<MFMessageComposeViewControllerDelegate> @end

ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
//点击任何处,短信分享
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{ //调用系统发送信息功能
BOOL canSendSMS = [MFMessageComposeViewController canSendText];
if (canSendSMS) { MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self; NSArray *array = [[NSArray alloc] initWithObjects:nil];
picker.recipients=array;
picker.view.frame=CGRectMake(0, 0, 320, 640);
[self presentViewController:picker animated:YES completion:nil]; }else{
UIAlertView*alert = [[UIAlertView alloc]initWithTitle:@""
message:@"当前设备不支持短信功能"
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alert show];
} }
#pragma -mark -系统消息回调
//系统发送信息的回调函数
-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{ //[self dismissModalViewControllerAnimated:YES];
[self dismissViewControllerAnimated:YES completion:nil];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
 
 

【代码笔记】iOS-短信分享的更多相关文章

  1. iOS 短信分享 邮件分享

    本地调用短信分享. #import "shareViewController.h" @interface shareViewController (){ UIAlertView * ...

  2. 整理:iOS 短信与电话事件的获取

    整理:iOS 短信与电话事件的获取   background information: Core Telephony iOS 4.0 的官方 API 裡頭,多了一個叫做 Core Telephony  ...

  3. 解决:People下面选择分享可见联系人,选择多个联系人后通过短信分享,短信中只显示一个联系人

    问题描述: [操作步骤]:People下导入导出中选择分享可见联系人,选择多个联系人后通过短信分享 [测试结果]:短信中只能显示一个联系人 [预期结果]:可以显示多个联系人 经过代码分析,从compo ...

  4. supersr--打电话/短信分享/邮件分享

    //  Created by apple on 15/6/17. //  Copyright (c) 2015年 Super All rights reserved. // #import " ...

  5. 基于android 社会的app短信分享 发送回调事件的实现

    摘要 前一段时间.由于项目的需要,采用ShareSDK该共享功能.其中包含 短信股吧.和呼叫系统,以分享要与成功处理服务器交互的消息后,(我不在乎在这里,收到.仅仅关心发出去了).可是ShareSDk ...

  6. iOS-调用系统的短信和发送邮件功能,实现短信分享和邮件分享

    一.邮件分享 1.iOS系统自带邮件设置邮箱(此处以QQ邮箱为例)(http://jingyan.baidu.com/album/6181c3e084cb7d152ef153b5.html?picin ...

  7. Android学习笔记之短信验证码的获取和读取

    PS:最近很多事情都拖拖拉拉的..都什么办事效率啊!!! 还得吐槽一下移动运营商,验证码超过五次的时候,直接把我的手机号封闭.真是受够了. 学习笔记: 1.Android之如何获取短信验证码. 2.如 ...

  8. ios短信和电话--参考

    调用打电话功能 [[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]]; 调 ...

  9. java代码实现调用短信接口,发送短信验证。

    一.代码示例 package com.aaa.zxf.login; import org.apache.commons.httpclient.HttpClient; import org.apache ...

随机推荐

  1. 解决ios开发中不合法的网络请求地址

    NSString *const kWebsite = @"http://image.baidu.com/search/index?tn=baiduimage&ipn=r&ct ...

  2. SQL 语句的TOP,Distinct语句

    --Top获取前几条数据,一般都与Order By连用 SELECT TOP 3 * FROM dbo.MyStudent --查询Student表中前3条所有的数据 SELECT TOP 3 S_N ...

  3. java实现的排序(插入/希尔/归并)

    java实现三种简单的排序,以下是代码: /*插入排序*/ public static void insertionSort(int[] a) { int j; for(int p = 1; p &l ...

  4. winform自定义日期控件,要求可以手动输入日期DatePicker

    要求:文本框中能手动输入数字,向上箭头根据鼠标位置给年月日递增,向下箭头递减 一:页面加载时: private void FlatDatePicker_Load(object sender, Even ...

  5. jquery 删除cookie失效的解决方法

    最近在做网站退出功能的时候出现删除Cookie 的时候总是失效. 1.使用$.cookie("name","");  结果出来是生成了一个新的空值的cookie ...

  6. spring笔记3 spring MVC的基础知识3

    4,spring MVC的视图 Controller得到模型数据之后,通过视图解析器生成视图,渲染发送给用户,用户就看到了结果. 视图:view接口,来个源码查看:它由视图解析器实例化,是无状态的,所 ...

  7. 导入项目时Loading descriptor ...

    最近导入了一个项目,始终在Loading descriptor ...,很长时间都没有结束. 这是Eclipse在从java.sun.com的服务器上下载配置文件,下载速度过慢导致的,其实配置文件不是 ...

  8. virtualbox创建com对象失败(解决方法)

      我的电脑是win7 64bit的,和舍友同时安装virtualbox,她的是win8,安装得很顺利. 我的就比较坎坷了,安装完打开后就出现了这个问题.   试过网上的好几个方法都不行,最后结合了两 ...

  9. 2016年湖南省第十二届大学生计算机程序设计竞赛---Parenthesis(线段树求区间最值)

    原题链接 http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1809 Description Bobo has a balanced parenthes ...

  10. Scalaz(26)- Lens: 函数式不可变对象数据操作方式

    scala中的case class是一种特殊的对象:由编译器(compiler)自动生成字段的getter和setter.如下面的例子: case class City(name:String, pr ...