iOS发送短信的代码

iOS发送短信的代码,第1张

概述iOS发送短信代码

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

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

    #pragma mark -发送短信      @interface VIEwController ()      {          UIAlertVIEw *mfAlertvIEw;//定义一个d出框      }                  -(voID)showMessageVIEwController      {          if( [MFMessageComposeVIEwController canSendText] )//判断是否能发短息      {                            MFMessageComposeVIEwController * controller = [[MFMessageComposeVIEwController alloc]init];              controller.recipIEnts = [NSArray arrayWithObject:@"10010"];//接收人,可以有很多,放入数组              controller.body = self.txYaoqingma.text;//短信内容,自定义即可              controller.messageComposeDelegate = self;//注意不是delegate                            [self presentVIEwController:controller animated:YES completion:nil];                            [[[[controller vIEwControllers] lastObject] navigationItem] setTitle:@"发送短信"];//修改短信界面标题          }          else          {                            UIAlertVIEw *alert=[[UIAlertVIEw alloc]initWithTitle:@"抱歉" message:@"短信功能不可用!" delegate:self cancelbuttonTitle:@"好" otherbuttonTitles:nil,nil nil];              [alert show];          }      }            //短信发送成功后的回调      -(voID)messageComposeVIEwController:(MFMessageComposeVIEwController *)controller dIDFinishWithResult:(MessageComposeResult)result      {          [controller dismissVIEwControllerAnimated:YES completion:nil];                    switch (result)          {              case MessageComposeResultCancelled:              {                  //用户取消发送              }                  break;                  case MessageComposeResultFailed://发送短信失败              {                  mfAlertvIEw=[[UIAlertVIEw alloc]initWithTitle:@"抱歉" message:@"短信发送失败" delegate:nil cancelbuttonTitle:@"好" otherbuttonTitles:nil,nil nil];                                    [mfAlertvIEw show];                               }                  break;              case MessageComposeResultSent:              {                  mfAlertvIEw=[[UIAlertVIEw alloc]initWithTitle:@"恭喜" message:@"短信发送成功!" delegate:nil cancelbuttonTitle:@"好" otherbuttonTitles:nil,nil nil];                                    [mfAlertvIEw show];                                }                  break;              default:                  break;          }      }  

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

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

总结

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

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存