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] ------------------