当前位置:   article > 正文

iOS开发 SMS本机短信_sms本机,读短信功能

sms本机,读短信功能

引入头文件

#import <MessageUI/MessageUI.h>

并添加delegate:

@interface InviteViewController : UIViewController<MFMessageComposeViewControllerDelegate>

.m中代码:

  1. - (IBAction)send:(id)sender
  2. {
  3. if( [MFMessageComposeViewController canSendText] ){
  4. MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc]init];
  5. controller.recipients = haveSelectedArray;//短信接收者,为array
  6. controller.body = _adTextView.text;//短信内容
  7. controller.messageComposeDelegate = self;
  8. [self presentModalViewController:controller animated:YES];
  9. [[[[controller viewControllers] lastObject] navigationItem] setTitle:@"叽歪邀请"];//修改短信界面标题
  10. }
  11. }
  12. //MFMessageComposeViewControllerDelegate
  13. - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
  14. [controller dismissModalViewControllerAnimated:NO];
  15. switch (result) {
  16. case MessageComposeResultCancelled:
  17. break;
  18. case MessageComposeResultFailed:// send failed
  19. break;
  20. case MessageComposeResultSent:
  21. break;
  22. default:
  23. break;
  24. }
  25. }



声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/525848
推荐阅读
相关标签
  

闽ICP备14008679号