IOS程式開發之跳轉簡訊發送介面實現傳送簡訊功能_IOS

來源:互聯網
上載者:User

項目需求:在程式開發中,我們需要在某個程式裡面發送一些簡訊驗證(不是接收簡訊驗證,關於簡訊驗證,傳送門:http://www.cnblogs.com/wolfhous/p/5096774.html

項目實現:

建立demo,直接看我源碼標誌.


源碼截圖


真機截圖


就是如此簡單,如您有任何問題/建議或者更好的實現方法,聯絡本人.

可以看我摺疊的源碼

/** 點擊傳送簡訊按鈕*/- (IBAction)sendMessageBut:(id)sender {/** 如果可以發送簡訊(不在模擬器情況下*/if ([MFMessageComposeViewController canSendText]) {/** 建立簡訊介面(控制器*/MFMessageComposeViewController *controller = [MFMessageComposeViewController new];controller.recipients = @[self.phoneTextField.text];//簡訊接受者為一個NSArray數組controller.body = self.messageBody.text;//簡訊內容controller.messageComposeDelegate = self;//設定代理,代理可不是 controller.delegate = self 哦!!!/** 取消按鈕的顏色(附帶,可不寫) */controller.navigationBar.tintColor = [UIColor redColor];[self presentViewController:controller animated:YES completion:nil];}else{NSLog(@"模擬器不支援傳送簡訊");}}#pragma mark - MFMessageComposeViewControllerDelegate/*** 協議方法,在資訊介面處理完資訊結果時調用(比如點擊發送,取消發送,發送失敗)** @param controller 資訊控制器* @param result 返回的資訊發送成功與否狀態*/- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{/** 發送完資訊就回到原程式*/[self dismissViewControllerAnimated:YES completion:nil];switch (result) {case MessageComposeResultSent:NSLog(@"發送成功");break;case MessageComposeResultFailed:NSLog(@"發送失敗");break;case MessageComposeResultCancelled:NSLog(@"發送取消");default:break;}}

以上就是本文給大家介紹的IOS程式開發之跳轉簡訊發送介面實現傳送簡訊功能的全部敘述,希望大家喜歡。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.