<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">拨打电话</span>
1: // 打电话
// 弊端:使用该方法进行拨号之后,当电话挂断之后不会返回应用程序, 会停留在通话记录界面
NSURL *url = [NSURL URLWithString:@"tel://13261936021"];
[[UIApplication sharedApplication] openURL:url];
2: // 在拨打电话之后会提示用户是否拨打, 当电话挂断之后会返回应用程序
// NSURL *url = [NSURL URLWithString:@"telprompt://13261936021"];
// [[UIApplication sharedApplication] openURL:url];
3:: @property (nonatomic, strong) UIWebView *webView;
if (_webView == nil) {
_webView = [[UIWebView alloc] initWithFrame:CGRectZero];
}
[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"tel://13261936021"]]];
发短信
1: // 如果利用该方式发送短信, 当短信发送完毕或者取消之后不会返回应用程序
NSURL *url = [NSURL URLWithString:@"sms://10010"];
[[UIApplication sharedApplication] openURL:url];
2
#import <MessageUI/MessageUI.h>
@interface NJShareViewController ()<MFMessageComposeViewControllerDelegate>
// 判断当前设备能否发送短信
if (![MFMessageComposeViewController canSendText]) {
NSLog(@"当前设备不能发送短信");
return ;
}
MFMessageComposeViewController *vc = [[MFMessageComposeViewController alloc] init];
// 设置短信内容
vc.body = @"吃饭了没?";
// 设置收件人列表
vc.recipients = @[@"10010"];
// 设置代理
vc.messageComposeDelegate = self;
// 显示控制器
[self presentViewController:vc animated:YES completion:nil];
#pragma mark - MFMessageComposeViewController
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
NSLog(@"didFinishWithResult");
[self dismissViewControllerAnimated:YES completion:^{
}];
if (MessageComposeResultCancelled == result) {
NSLog(@"取消发送");
}else if (MessageComposeResultSent == result)
{
NSLog(@"发送成功");
}else
{
NSLog(@"发送失败");
}
}
发邮件
1
// 当邮件发送成功或者失败或者取消之后不会回到原来的应用程序
NSURL *url = [NSURL URLWithString:@"mailto://10010@qq.com"];
[[UIApplication sharedApplication] openURL:url];
2
#import <MessageUI/MessageUI.h>
@interface NJShareViewController ()< MFMailComposeViewControllerDelegate>
// 不能发邮件
if (![MFMailComposeViewController canSendMail]) return;
// 当邮件发送成功或者失败或者取消之后会回到原始程序
MFMailComposeViewController *vc = [[MFMailComposeViewController alloc] init];
// 设置邮件主题
[vc setSubject:@"会议"];
// 设置邮件内容
[vc setMessageBody:@"今天下午开会吧" isHTML:NO];
// 设置收件人列表
[vc setToRecipients:@[@"643055866@qq.com"]];
// 设置抄送人列表
[vc setCcRecipients:@[@"1234@qq.com"]];
// 设置密送人列表
[vc setBccRecipients:@[@"56789@qq.com"]];
// 添加附件(一张图片)
UIImage *image = [UIImage imageNamed:@"lufy.jpeg"];
NSData *data = UIImageJPEGRepresentation(image, 0.5);
[vc addAttachmentData:data mimeType:@"image/jepg" fileName:@"lufy.jpeg"];
// 设置代理
vc.mailComposeDelegate = self;
// 显示控制器
[self presentViewController:vc animated:YES completion:nil];
#pragma mark - MFMailComposeViewControllerDelegate
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
// 关闭邮件界面
[controller dismissViewControllerAnimated:YES completion:nil];
if (result == MFMailComposeResultCancelled) {
NSLog(@"取消发送");
} else if (result == MFMailComposeResultSent) {
NSLog(@"已经发出");
} else {
NSLog(@"发送失败");
}
}
评分支持
NSString *appid = @"717804289"; // 自己企业的app的aped。
NSString *str = [NSString stringWithFormat:
@"itms-apps://itunes.apple.com/cn/app/id%@?mt=8", appid];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
aped的寻找路径
在程序内打开一个app
// 协议头://地址/路径
// ooopop://com.lo.mow
NSURL *url = [NSURL URLWithString:@"ooopop://com.lo.mow"];
[[UIApplication sharedApplication] openURL:url];