IOS Program Development in progress-jump to the send text message interface to achieve text messaging, ios Program Development

Source: Internet
Author: User

IOS Program Development in progress-jump to the send text message interface to achieve text messaging, ios Program Development

I found that my title is not good. Who can help me pick up the title that undertakes the context? Comment, I change

Project requirements: In program development, we need to send some text message verification in a program (not to receive text message verification, about text message verification, portal:Http://www.cnblogs.com/wolfhous/p/5096774.html

Project implementation:

------------- Wolfhous ------------------

Create a demo and check my source code.

------------ Wolfhous ------------------

Source code

------------ Wolfhous ------------------

Real Machine

------------ Wolfhous ------------------

It is so simple. If you have any questions/suggestions or better implementation methods, contact me.

See the collapsed source code.

1/** click the send SMS button */2-(IBAction) sendMessageBut :( id) sender {3/** if you can send text messages (not in the case of simulators */4 if ([MFMessageComposeViewController canSendText]) {5/** create the SMS interface (controller */6 MFMessageComposeViewController * controller = [MFMessageComposeViewController new]; 7 controller. recipients = @ [self. phoneTextField. text]; // The text message recipient is an NSArray array 8 controller. body = self. messageBody. text; // SMS content 9 controller. messagecomposedel.pdf Te = self; // set proxy. The proxy is not controller. delegate = self !!! 10/** color of the cancel button (included, do not write) */11 controller. navigationBar. tintColor = [UIColor redColor]; 12 [self presentViewController: controller animated: YES completion: nil]; 13} else {14 NSLog (@ "the simulator does not support sending text messages "); 15} 16} 17 # pragma mark-MFMessageComposeViewControllerDelegate18/** 19 * protocol method, called when the information result is processed on the information interface (for example, click send, cancel send, and send failed) 20*21 * @ param controller information controller 22 * @ param result returned message status 23 */24-(void) messageComposeViewController :( MFMessageComposeViewController *) controller didFinishWithResult :( MessageComposeResult) result25 {26/** returns to the original program after the message is sent */27 [self dismissViewControllerAnimated: YES completion: nil]; 28 switch (result) {29 case MessageComposeResultSent: 30 NSLog (@ "sent successfully"); 31 break; 32 case MessageComposeResultFailed: 33 NSLog (@ "failed to send"); 34 break; 35 case MessageComposeResultCancelled: 36 NSLog (@ "cancel sending"); 37 default: 38 break; 39} 40}View Code

 

----------- Wolfhous ------------- [reprinted please indicate the source] ------------------

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.