iOS点击发送短信按钮跳转到手机短信界面实现发送短信

iOS点击发送短信按钮跳转到手机短信界面实现发送短信,第1张

概述iOS点击发送短信按钮跳转到手机短信界面实现发送短信

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

#import "VIEwController.h" @interface VIEwController () @end @implementation VIEwController - (voID)vIEwDIDLoad {    [super vIEwDIDLoad];    NSLog(@"%@",NSHomeDirectory());    UIbutton *button = [UIbutton buttonWithType:UIbuttonTypeCustom];    button.frame = CGRectMake(100,100,40,30);    [button setTitle:@"发送" forState:UIControlStatenormal];    [button setTitlecolor:[UIcolor blackcolor] forState:UIControlStatenormal];    button.backgroundcolor=[UIcolor redcolor];    [self.vIEw addSubvIEw:button];    [button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventtouchUpInsIDe];} - (voID)buttonClick {        //首先判断当前设备是否可以发送短信    if([MFMessageComposeVIEwController canSendText])    {        MFMessageComposeVIEwController *mc=[[MFMessageComposeVIEwController alloc] init];                 //设置委托        mc.messageComposeDelegate=self;                 //短信内容        mc.body=[[Nsstring alloc] initWithUTF8String:"你好啊" ];                 //设置短信收件方        mc.recipIEnts=[NSArray arrayWithObject:@"10010"];                 [self presentVIEwController:mc animated:YES completion:nil];    }else{             [[[UIAlertVIEw alloc] initWithTitle:nil message:@"抱歉,没有此功能" delegate:self cancelbuttonTitle:@"✅"                          otherbuttonTitles:nil,nil] show];         }}     //短信发送的处理结果-(voID)messageComposeVIEwController:(MFMessageComposeVIEwController *)controller dIDFinishWithResult:(MessageComposeResult)result{    switch (result)    {        case MessageComposeResultSent:            NSLog(@"text message sent successfully");            break;        case MessageComposeResultCancelled:            NSLog(@"text message cancelled");            [self dismissVIEwControllerAnimated:YES completion:nil];            break;        case MessageComposeResultFailed:            NSLog(@"text message Failed");            break;        default:            NSLog(@"error happens");            break;      }     }@end

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的iOS点击发送短信按钮跳转到手机短信界面实现发送短信全部内容,希望文章能够帮你解决iOS点击发送短信按钮跳转到手机短信界面实现发送短信所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1105938.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存