首页 技术 正文
技术 2022年11月17日
0 收藏 965 点赞 3,172 浏览 1760 个字

1.发短信

头文件

#import <MessageUI/MessageUI.h>

头部代理

@interface ViewController ()<MFMessageComposeViewControllerDelegate>

发送信息

- (void)senderMessage{
if([MFMessageComposeViewController canSendText]) {
///短信实例化
MFMessageComposeViewController * messageVc = [[MFMessageComposeViewController alloc] init];
///目标号码,可以多个
messageVc.recipients = @[@"",@""];
messageVc.navigationBar.tintColor = [UIColor redColor];
messageVc.body = @"发送的内容-发送的内容-发送的内容";
messageVc.messageComposeDelegate = self;
[self presentViewController:messageVc animated:YES completion:nil];
[[[[messageVc viewControllers] lastObject] navigationItem] setTitle:@"title"];
}
else {
NSLog(@"当前设备不支持短信功能");
}}

代理方法实现

-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
///dismiss MFMessageComposeViewController
[controller dismissViewControllerAnimated:YES completion:nil];
if (result == MessageComposeResultSent) {
NSLog(@"信息发送成功!");
}
else if (result == MessageComposeResultFailed){
NSLog(@"信息发送失败!");
}
else if (result == MessageComposeResultCancelled){
NSLog(@"点击了取消");
}
else{ }
}

2.拨打电话

- (void)dialPhone{
///该方法直接拨打,不会弹出呼叫(取消)
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"tel://18888888888"]]; ///该方法会弹出是否取消呼叫
UIWebView*callWebview =[[UIWebView alloc] init];
NSURL *telURL =[NSURL URLWithString:@"tel:18888888888"];
[callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
[self.view addSubview:callWebview];
}

3.发送邮件

- (void)senderEmail{
NSString *urlStr =@"mailto:xxxxxxxx@xxxx.com?subject=邮件主题(此参数可不传)&body=邮件内容(此参数可不传)";
NSURL *url = [NSURL URLWithString:urlStr] ;
[[UIApplication sharedApplication] openURL:url];
}

4.发送QQ消息

- (void)senderQQ{
///111111111111为QQ号码
NSString *url = @"mqq://im/chat?chat_type=wpa&uin=111111111111&version=1&src_type=web";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,489
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,904
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,489
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,290