如何利用系統的MFMessageComposeViewController進行短信發送
如何利用系統的Message進行短信發送1、導入包 MessageUI.framework2、主要內容(1) 代碼主題部分 MFMessageComposeViewController* controller = [[MFMessageComposeViewControlleralloc] init]; //Before presenting a message composition view, call the canSendText class method to ensure that the user’s device is appropriately configured if ([MFMessageComposeViewControllercanSendText]) { //The initial content of the message controller.body = message; //An array of strings containing the initial recipients of the message. controller.recipients = substrings; // 代理方法 controller.messageComposeDelegate = self; [selfpresentModalViewController:controller animated:YES];(2) 執行代理方法 //Tells the delegate that the user finished composing the message -(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result { [selfdismissModalViewControllerAnimated:YES]; if (result == MessageComposeResultCancelled) NSLog(@"Message cancelled"); elseif (result == MessageComposeResultSent) NSLog(@"Message sent"); else NSLog(@"Message failed"); }總結:(1) 發送短信之前,需要驗證設備是否具有發送短信的能力(2) property Message 即為短信的內容(3) property recipents 即為短信的發送人信息,註意,其類型為NSArray2013 - 01 - 02上島